Skip to content

Commit

Permalink
Added specs for watchOS support.
Browse files Browse the repository at this point in the history
  • Loading branch information
neonichu committed Jun 24, 2015
1 parent a8487bf commit 73b41ed
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
23 changes: 23 additions & 0 deletions spec/project/object/native_target_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ module ProjectSpecs
t2 = @project.new_target(:static_library, 'Pods', :osx)
t2.build_configuration_list.set_setting('SDKROOT', 'macosx10.8')
t2.sdk_version.should == '10.8'

t3 = @project.new_target(:static_library, 'Pods', :watchos)
t3.build_configuration_list.set_setting('SDKROOT', 'watchos2.0')
t3.sdk_version.should == '2.0'
end

describe 'returns the deployment target specified in its build configuration' do
Expand All @@ -134,6 +138,11 @@ module ProjectSpecs
@project.build_configuration_list.set_setting('MACOSX_DEPLOYMENT_TARGET', nil)
@project.new_target(:static_library, 'Pods', :osx, '10.7').deployment_target.should == '10.7'
end

it 'works for watchOS' do
@project.build_configuration_list.set_setting('WATCHOS_DEPLOYMENT_TARGET', nil)
@project.new_target(:static_library, 'Pods', :watchos, '2.0').deployment_target.should == '2.0'
end
end

describe 'returns the deployment target of the project build configuration' do
Expand All @@ -150,6 +159,13 @@ module ProjectSpecs
osx_target.build_configurations.first.build_settings['MACOSX_DEPLOYMENT_TARGET'] = nil
osx_target.deployment_target.should == '10.7'
end

it 'works for watchOS' do
@project.build_configuration_list.set_setting('WATCHOS_DEPLOYMENT_TARGET', '2.0')
watch_target = @project.new_target(:static_library, 'Pods', :watchos)
watch_target.build_configurations.first.build_settings['WATCHOS_DEPLOYMENT_TARGET'] = nil
watch_target.deployment_target.should == '2.0'
end
end

it 'returns the build configuration' do
Expand Down Expand Up @@ -347,6 +363,13 @@ module ProjectSpecs
file.path.scan(/\d\.\d/).first.should == Xcodeproj::Constants::LAST_KNOWN_IOS_SDK
end

it 'uses the last known watchOS SDK version if none is specified in the target' do
@target.build_configuration_list.set_setting('SDKROOT', 'watchos')
@target.add_system_framework('WatchConnectivity')
file = @project['Frameworks/watchOS'].files.first
file.path.scan(/\d\.\d/).first.should == Xcodeproj::Constants::LAST_KNOWN_WATCHOS_SDK
end

it "doesn't duplicate references to a frameworks if one already exists" do
@target.add_system_framework('QuartzCore')
@target.add_system_framework('QuartzCore')
Expand Down
18 changes: 18 additions & 0 deletions spec/project/project_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ module ProjectSpecs
target.build_phases.map(&:isa).sort.should == %w(PBXFrameworksBuildPhase PBXSourcesBuildPhase)
end

it 'creates a new watchOS target' do
target = @helper.new_target(@project, :static_library, 'Pods', :watchos, '2.0', @project.products_group, :objc)
target.name.should == 'Pods'
target.product_type.should == 'com.apple.product-type.library.static'

target.build_configuration_list.should.not.be.nil
configurations = target.build_configuration_list.build_configurations
configurations.map(&:name).sort.should == %w(Debug Release)
build_settings = configurations.first.build_settings
build_settings['WATCHOS_DEPLOYMENT_TARGET'].should == '2.0'
build_settings['SDKROOT'].should == 'watchos'

@project.targets.should.include target
@project.products.should.include target.product_reference

target.build_phases.map(&:isa).sort.should == %w(PBXFrameworksBuildPhase PBXSourcesBuildPhase)
end

it 'uses default build settings for Release and Debug configurations' do
target = @helper.new_target(@project, :static_library, 'Pods', :ios, '6.0', @project.products_group, :objc)
debug_settings = @helper.common_build_settings(:debug, :ios, '6.0', :static_library)
Expand Down
12 changes: 11 additions & 1 deletion spec/xcodebuild_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
iOS Simulator SDKs:
Simulator - iOS 6.1 -sdk iphonesimulator6.1
watchOS SDKs:
Watch OS 2.0 -sdk watchos2.0
watchOS Simulator SDKs:
Simulator - Watch OS 2.0 -sdk watchsimulator2.0
DOC
# rubocop:enable Style/Tab

Expand All @@ -35,6 +41,10 @@ module Xcodeproj
it 'returns the last OS X SDK' do
@helper.last_osx_sdk.should == '10.8'
end

it 'returns the last watchOS SDK' do
@helper.last_watchos_sdk.should == '2.0'
end
end

#--------------------------------------------------------------------------------#
Expand All @@ -55,7 +65,7 @@ module Xcodeproj
describe '#parse_sdks_information' do
it 'parses the skds information returned by xcodebuild' do
result = @helper.send(:parse_sdks_information, SPEC_XCODEBUILD_SAMPLE_SDK_OTPUT)
result.should == [['macosx', '10.7'], ['macosx', '10.8'], ['iphoneos', '6.1']]
result.should == [['macosx', '10.7'], ['macosx', '10.8'], ['iphoneos', '6.1'], ['watchos', '2.0']]
end
end
end
Expand Down

0 comments on commit 73b41ed

Please sign in to comment.