From 73b41ed92027baedf5b50e2ccafb130307602840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boris=20Bu=CC=88gling?= Date: Wed, 24 Jun 2015 23:48:25 +0200 Subject: [PATCH] Added specs for watchOS support. --- spec/project/object/native_target_spec.rb | 23 +++++++++++++++++++++++ spec/project/project_helper_spec.rb | 18 ++++++++++++++++++ spec/xcodebuild_helper_spec.rb | 12 +++++++++++- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/spec/project/object/native_target_spec.rb b/spec/project/object/native_target_spec.rb index 71cfd8426..a418ffbae 100644 --- a/spec/project/object/native_target_spec.rb +++ b/spec/project/object/native_target_spec.rb @@ -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 @@ -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 @@ -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 @@ -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') diff --git a/spec/project/project_helper_spec.rb b/spec/project/project_helper_spec.rb index ed43fc923..d4dd0d013 100644 --- a/spec/project/project_helper_spec.rb +++ b/spec/project/project_helper_spec.rb @@ -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) diff --git a/spec/xcodebuild_helper_spec.rb b/spec/xcodebuild_helper_spec.rb index bd35f9a80..6451ea625 100644 --- a/spec/xcodebuild_helper_spec.rb +++ b/spec/xcodebuild_helper_spec.rb @@ -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 @@ -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 #--------------------------------------------------------------------------------# @@ -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