[InstallationOptions] Add #share_schemes_for_development_pods

This allows for opting out of sharing schemes for development pods.
By default, the current behavior is kept -- all dev pods have their
schemes shared. By setting the option to `nil` or `false`, no schemes
are shared. Otherwise, an array can be passed, and only dev pod names that
match elements of that array will have their schemes shared.
parent f18245f3
...@@ -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, true
module Mixin module Mixin
module ClassMethods module ClassMethods
......
...@@ -62,6 +62,7 @@ module Pod ...@@ -62,6 +62,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' => true,
} }
end end
......
...@@ -749,18 +749,83 @@ module Pod ...@@ -749,18 +749,83 @@ 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 'shares by default' do
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( Xcodeproj::XCScheme.expects(:share_scheme).with(
@installer.pods_project.path, @installer.pods_project.path,
'BananaLib') 'BananaLib')
@installer.send(:share_development_pod_schemes)
@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
it 'allows specifying regular expressions of pods to share' do
@installer.installation_options.
stubs(:share_schemes_for_development_pods).
returns([/bAnaNalIb/i, /B*/])
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