Skip to content

Commit

Permalink
Merge pull request #6558 from dnkoutso/fix_regression
Browse files Browse the repository at this point in the history
Only share pod target xcscheme if present during validation.
  • Loading branch information
dnkoutso committed Mar 14, 2017
2 parents 9d078b8 + 2222aaa commit f5d7b5b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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)
Expand Down
7 changes: 6 additions & 1 deletion lib/cocoapods/validator.rb
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions spec/unit/validator_spec.rb
Expand Up @@ -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)

Expand All @@ -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)

Expand All @@ -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
Expand Down

0 comments on commit f5d7b5b

Please sign in to comment.