Commit 4c4b69bd authored by Samuel Giddins's avatar Samuel Giddins

Merge pull request #5254 from CocoaPods/seg-opt-out-sharing-scheme

[InstallationOptions] Add #share_schemes_for_development_pods
parents f18245f3 78f85a1a
...@@ -16,6 +16,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -16,6 +16,11 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Orta Therox](https://github.com/orta) [Orta Therox](https://github.com/orta)
[#5260](https://github.com/CocoaPods/CocoaPods/issues/5260) [#5260](https://github.com/CocoaPods/CocoaPods/issues/5260)
* Make sharing schemes for development pods an installation option
(`share_schemes_for_development_pods`) and disable sharing schemes
by default.
[Samuel Giddins](https://github.com/segiddins)
##### Bug Fixes ##### Bug Fixes
* None. * None.
......
...@@ -703,10 +703,29 @@ module Pod ...@@ -703,10 +703,29 @@ module Pod
# #
def share_development_pod_schemes def share_development_pod_schemes
development_pod_targets.select(&:should_build?).each do |pod_target| development_pod_targets.select(&:should_build?).each do |pod_target|
next unless share_scheme_for_development_pod?(pod_target.pod_name)
Xcodeproj::XCScheme.share_scheme(pods_project.path, pod_target.label) Xcodeproj::XCScheme.share_scheme(pods_project.path, pod_target.label)
end end
end end
# @param [String] pod The root name of the development pod.
#
# @return [Bool] whether the scheme for the given development pod should be
# shared.
#
def share_scheme_for_development_pod?(pod)
case dev_pods_to_share = installation_options.share_schemes_for_development_pods
when TrueClass, FalseClass, NilClass
dev_pods_to_share
when Array
dev_pods_to_share.any? { |dev_pod| dev_pod === pod } # rubocop:disable Style/CaseEquality
else
raise Informative, 'Unable to handle share_schemes_for_development_pods ' \
"being set to #{dev_pods_to_share.inspect} -- please set it to true, " \
'false, or an array of pods to share schemes for.'
end
end
# Writes the Podfile and the lock files. # Writes the Podfile and the lock files.
# #
# @todo Pass the checkout options to the Lockfile. # @todo Pass the checkout options to the Lockfile.
......
...@@ -106,6 +106,7 @@ module Pod ...@@ -106,6 +106,7 @@ module Pod
option :deterministic_uuids, true option :deterministic_uuids, true
option :integrate_targets, true option :integrate_targets, true
option :lock_pod_sources, true option :lock_pod_sources, true
option :share_schemes_for_development_pods, false
module Mixin module Mixin
module ClassMethods module ClassMethods
......
...@@ -9,6 +9,7 @@ module Pod ...@@ -9,6 +9,7 @@ module Pod
'deterministic_uuids' => true, 'deterministic_uuids' => true,
'integrate_targets' => true, 'integrate_targets' => true,
'lock_pod_sources' => true, 'lock_pod_sources' => true,
'share_schemes_for_development_pods' => false,
}.each do |option, default| }.each do |option, default|
it "includes `#{option}` defaulting to `#{default}`" do it "includes `#{option}` defaulting to `#{default}`" do
Installer::InstallationOptions.defaults.fetch(option).should == default Installer::InstallationOptions.defaults.fetch(option).should == default
...@@ -62,6 +63,7 @@ module Pod ...@@ -62,6 +63,7 @@ module Pod
'deterministic_uuids' => false, 'deterministic_uuids' => false,
'integrate_targets' => true, 'integrate_targets' => true,
'lock_pod_sources' => true, 'lock_pod_sources' => true,
'share_schemes_for_development_pods' => false,
} }
end end
......
...@@ -749,18 +749,92 @@ module Pod ...@@ -749,18 +749,92 @@ module Pod
@installer.send(:write_pod_project) @installer.send(:write_pod_project)
end end
it 'shares schemes of development pods' do describe 'sharing schemes of development pods' do
spec = fixture_spec('banana-lib/BananaLib.podspec') before do
pod_target = fixture_pod_target(spec) spec = fixture_spec('banana-lib/BananaLib.podspec')
pod_target = fixture_pod_target(spec)
@installer.stubs(:pod_targets).returns([pod_target]) @installer.stubs(:pod_targets).returns([pod_target])
@installer.sandbox.stubs(:development_pods).returns('BananaLib' => nil) @installer.sandbox.stubs(:development_pods).returns('BananaLib' => nil)
end
it 'does not share by default' do
Xcodeproj::XCScheme.expects(:share_scheme).never
@installer.send(:share_development_pod_schemes)
end
it 'can share all schemes' do
@installer.installation_options.
stubs(:share_schemes_for_development_pods).
returns(true)
Xcodeproj::XCScheme.expects(:share_scheme).with(
@installer.pods_project.path,
'BananaLib')
@installer.send(:share_development_pod_schemes)
end
it 'allows opting out' do
@installer.installation_options.
stubs(:share_schemes_for_development_pods).
returns(false)
Xcodeproj::XCScheme.expects(:share_scheme).never
@installer.send(:share_development_pod_schemes)
@installer.installation_options.
stubs(:share_schemes_for_development_pods).
returns(nil)
Xcodeproj::XCScheme.expects(:share_scheme).never
@installer.send(:share_development_pod_schemes)
end
it 'allows specifying strings of pods to share' do
@installer.installation_options.
stubs(:share_schemes_for_development_pods).
returns(%w(BananaLib))
Xcodeproj::XCScheme.expects(:share_scheme).with(
@installer.pods_project.path,
'BananaLib')
@installer.send(:share_development_pod_schemes)
@installer.installation_options.
stubs(:share_schemes_for_development_pods).
returns(%w(orange-framework))
Xcodeproj::XCScheme.expects(:share_scheme).never
@installer.send(:share_development_pod_schemes)
end
Xcodeproj::XCScheme.expects(:share_scheme).with( it 'allows specifying regular expressions of pods to share' do
@installer.pods_project.path, @installer.installation_options.
'BananaLib') stubs(:share_schemes_for_development_pods).
returns([/bAnaNalIb/i, /B*/])
@installer.send(:share_development_pod_schemes) Xcodeproj::XCScheme.expects(:share_scheme).with(
@installer.pods_project.path,
'BananaLib')
@installer.send(:share_development_pod_schemes)
@installer.installation_options.
stubs(:share_schemes_for_development_pods).
returns([/banana$/, /[^\A]BananaLib/])
Xcodeproj::XCScheme.expects(:share_scheme).never
@installer.send(:share_development_pod_schemes)
end
it 'raises when an invalid type is set' do
@installer.installation_options.
stubs(:share_schemes_for_development_pods).
returns(Pathname('foo'))
Xcodeproj::XCScheme.expects(:share_scheme).never
e = should.raise(Informative) { @installer.send(:share_development_pod_schemes) }
e.message.should.match /share_schemes_for_development_pods.*set it to true, false, or an array of pods to share schemes for/
end
end end
it "uses the user project's object version for the pods project" do it "uses the user project's object version for the pods project" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment