Commit 467beead authored by Dimitris Koutsogiorgas's avatar Dimitris Koutsogiorgas Committed by GitHub

Merge pull request #7110 from dnkoutso/warning_script_phases

Warn when a pod that was added or changed includes script phases
parents e504e0c8 bd809d25
......@@ -30,6 +30,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
##### Bug Fixes
* Warn when a pod that was added or changed includes script phases
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#7110](https://github.com/CocoaPods/CocoaPods/pull/7110)
* Build pod targets with script phases and integrate them properly
[Dimitris Koutsogiorgas](https://github.com/dnkoutso)
[#7104](https://github.com/CocoaPods/CocoaPods/pull/7104)
......
......@@ -355,7 +355,7 @@ module Pod
end
# Install the Pods. If the resolver indicated that a Pod should be
# installed and it exits, it is removed an then reinstalled. In any case if
# installed and it exits, it is removed and then reinstalled. In any case if
# the Pod doesn't exits it is installed.
#
# @return [void]
......@@ -423,6 +423,7 @@ module Pod
unlock_pod_sources
run_plugins_post_install_hooks
warn_for_deprecations
warn_for_installed_script_phases
lock_pod_sources
print_post_install_message
end
......@@ -523,6 +524,24 @@ module Pod
end
end
# Prints a warning for any pods that included script phases
#
# @return [void]
#
def warn_for_installed_script_phases
pods_to_install = sandbox_state.added | sandbox_state.changed
pod_targets.each do |pod_target|
spec = pod_target.root_spec
if pods_to_install.include?(spec.name)
script_phase_count = pod_target.script_phases.count
unless script_phase_count.zero?
UI.warn "#{spec.name} has added #{pod_target.script_phases.count} #{'script phase'.pluralize(script_phase_count)}. " \
'Please inspect before executing a build. See `https://guides.cocoapods.org/syntax/podspec.html#script_phases` for more information.'
end
end
end
end
# Writes the Podfile and the lock files.
#
# @todo Pass the checkout options to the Lockfile.
......@@ -626,19 +645,6 @@ module Pod
#-------------------------------------------------------------------------#
public
# @return [Array<Library>] The targets of the development pods generated by
# the installation process.
#
def development_pod_targets
pod_targets.select do |pod_target|
sandbox.development_pods.keys.include?(pod_target.pod_name)
end
end
#-------------------------------------------------------------------------#
private
# @!group Private helpers
......
......@@ -185,10 +185,16 @@ module Pod
end
end
# @return [Array<Hash{Symbol=>String}>] An array of hashes where each hash represents a single script phase.
#
def script_phases
spec_consumers.map(&:script_phases).flatten
end
# @return [Boolean] Whether the target contains any script phases.
#
def contains_script_phases?
!spec_consumers.map(&:script_phases).flatten.empty?
!script_phases.empty?
end
# @return [Hash{Array => Specification}] a hash where the keys are the test native targets and the value
......
......@@ -514,6 +514,35 @@ module Pod
end.message.should.include 'Could not install \'RandomPod\' pod. There is no target that supports it.'
end
it 'prints a warning for installed pods that included script phases' do
spec = fixture_spec('coconut-lib/CoconutLib.podspec')
spec.test_specs.first.script_phase = { :name => 'Hello World', :script => 'echo "Hello World"' }
pod_target = PodTarget.new([spec, *spec.test_specs], [fixture_target_definition], config.sandbox)
pod_target.stubs(:platform).returns(:ios)
sandbox_state = Installer::Analyzer::SpecsState.new
sandbox_state.added << 'CoconutLib'
@installer.stubs(:pod_targets).returns([pod_target])
@installer.stubs(:root_specs).returns([spec])
@installer.stubs(:sandbox_state).returns(sandbox_state)
@installer.send(:warn_for_installed_script_phases)
UI.warnings.should.include 'CoconutLib has added 1 script phase. Please inspect before executing a build. ' \
'See `https://guides.cocoapods.org/syntax/podspec.html#script_phases` for more information.'
end
it 'does not print a warning for already installed pods that include script phases' do
spec = fixture_spec('coconut-lib/CoconutLib.podspec')
spec.test_specs.first.script_phase = { :name => 'Hello World', :script => 'echo "Hello World"' }
pod_target = PodTarget.new([spec, *spec.test_specs], [fixture_target_definition], config.sandbox)
pod_target.stubs(:platform).returns(:ios)
sandbox_state = Installer::Analyzer::SpecsState.new
sandbox_state.unchanged << 'CoconutLib'
@installer.stubs(:pod_targets).returns([pod_target])
@installer.stubs(:root_specs).returns([spec])
@installer.stubs(:sandbox_state).returns(sandbox_state)
@installer.send(:warn_for_installed_script_phases)
UI.warnings.should.be.empty
end
#--------------------------------------#
describe '#clean' 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