From 2222aaaf491bf6979b545dec96025942e9ed8adf Mon Sep 17 00:00:00 2001 From: Dimitris Koutsogiorgas Date: Tue, 14 Mar 2017 11:40:06 -0700 Subject: [PATCH] Only share pod target xcscheme if present during validation. --- CHANGELOG.md | 4 ++++ lib/cocoapods/validator.rb | 7 ++++++- spec/unit/validator_spec.rb | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 589cf6d76c..d8be1c723a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ##### Bug Fixes +* Only share pod target xcscheme if present during validation. + [Dimitris Koutsogiorgas](https://github.com/dnkoutso) + [#6558](https://github.com/CocoaPods/CocoaPods/pull/6558) + * Properly compile storyboard for watch device family. [Dimitris Koutsogiorgas](https://github.com/dnkoutso) [#6516](https://github.com/CocoaPods/CocoaPods/issues/6516) diff --git a/lib/cocoapods/validator.rb b/lib/cocoapods/validator.rb index d60862e0fe..957e3294b9 100644 --- a/lib/cocoapods/validator.rb +++ b/lib/cocoapods/validator.rb @@ -428,7 +428,8 @@ def add_app_project_import add_xctest(app_target) if @installer.pod_targets.any? { |pt| pt.spec_consumers.any? { |c| c.frameworks.include?('XCTest') } } app_project.save Xcodeproj::XCScheme.share_scheme(app_project.path, 'App') - Xcodeproj::XCScheme.share_scheme(@installer.pods_project.path, pod_target.label) + # Share the pods xcscheme only if it exists. For pre-built vendored pods there is no xcscheme generated. + Xcodeproj::XCScheme.share_scheme(@installer.pods_project.path, pod_target.label) if shares_pod_target_xcscheme?(pod_target) end def add_swift_version(app_target) @@ -669,6 +670,10 @@ def note(*args) add_result(:note, *args) end + def shares_pod_target_xcscheme?(pod_target) + Pathname.new(@installer.pods_project.path + pod_target.label).exist? + end + def add_result(type, attribute_name, message, public_only = false) result = results.find do |r| r.type == type && r.attribute_name && r.message == message && r.public_only? == public_only diff --git a/spec/unit/validator_spec.rb b/spec/unit/validator_spec.rb index 2b65365280..3d41fb9890 100644 --- a/spec/unit/validator_spec.rb +++ b/spec/unit/validator_spec.rb @@ -614,6 +614,7 @@ def podspec_path(name = 'JSONKit', version = '1.4') installer.stubs(:pods_project).returns(pods_project) Xcodeproj::XCScheme.expects(:share_scheme).with(app_project_path, 'App').once Xcodeproj::XCScheme.expects(:share_scheme).with(pods_project.path, 'BananaLib').once + @validator.stubs(:shares_pod_target_xcscheme?).returns(true) @validator.instance_variable_set(:@installer, installer) @validator.send(:add_app_project_import) @@ -636,6 +637,7 @@ def podspec_path(name = 'JSONKit', version = '1.4') installer.stubs(:pods_project).returns(pods_project) Xcodeproj::XCScheme.expects(:share_scheme).with(app_project_path, 'App').once Xcodeproj::XCScheme.expects(:share_scheme).with(pods_project.path, 'BananaLib').once + @validator.stubs(:shares_pod_target_xcscheme?).returns(true) @validator.instance_variable_set(:@installer, installer) @validator.send(:add_app_project_import) @@ -644,6 +646,22 @@ def podspec_path(name = 'JSONKit', version = '1.4') bc.build_settings['FRAMEWORK_SEARCH_PATHS'] end.uniq.should == [%w($(inherited) "$(PLATFORM_DIR)/Developer/Library/Frameworks")] end + + it 'does not share xcscheme for pod target if there isnt one' do + @validator.send(:create_app_project) + pods_project = Xcodeproj::Project.new(@validator.validation_dir + 'Pods/Pods.xcodeproj') + app_project_path = @validator.validation_dir + 'App.xcodeproj' + pod_target = fixture_pod_target('banana-lib/BananaLib.podspec') + pod_target.stubs(:uses_swift? => true, :pod_name => 'JSONKit') + pod_target.spec_consumers.first.stubs(:frameworks).returns(%w(XCTest)) + installer = stub(:pod_targets => [pod_target]) + installer.stubs(:pods_project).returns(pods_project) + Xcodeproj::XCScheme.expects(:share_scheme).with(app_project_path, 'App').once + Xcodeproj::XCScheme.expects(:share_scheme).with(pods_project.path, 'BananaLib').never + @validator.stubs(:shares_pod_target_xcscheme?).returns(false) + @validator.instance_variable_set(:@installer, installer) + @validator.send(:add_app_project_import) + end end describe 'file pattern validation' do