Commit 4c6ecd43 authored by Samuel E. Giddins's avatar Samuel E. Giddins

Merge pull request #4544 from CocoaPods/seg-properly-integrate-all-targets

Ensure all user projects are properly integrated
parents 08bd4c95 d14f40f5
...@@ -89,6 +89,18 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -89,6 +89,18 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Samuel Giddins](https://github.com/segiddins) [Samuel Giddins](https://github.com/segiddins)
[#3347](https://github.com/CocoaPods/CocoaPods/issues/3347) [#3347](https://github.com/CocoaPods/CocoaPods/issues/3347)
* Targets that are no longer integrated with CocoaPods will be properly
de-integrated when installation occurs.
[Samuel Giddins](https://github.com/segiddins)
* Targets that are integrated will be ensured that they have all
CocoaPods-related settings and phases properly installed.
[Samuel Giddins](https://github.com/segiddins)
* Total de-integration will happen whenever the major version of CocoaPods
changes, ensuring backwards-incompatible changes are properly applied.
[Samuel Giddins](https://github.com/segiddins)
##### Bug Fixes ##### Bug Fixes
* Fix compiling of asset catalog files inside resource bundles. * Fix compiling of asset catalog files inside resource bundles.
...@@ -158,6 +170,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre` ...@@ -158,6 +170,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Samuel Giddins](https://github.com/segiddins) [Samuel Giddins](https://github.com/segiddins)
[#4521](https://github.com/CocoaPods/CocoaPods/issues/4521) [#4521](https://github.com/CocoaPods/CocoaPods/issues/4521)
* Changing the name of a target in a Podfile will no longer cause warnings about
being unable to set the base configuration XCConfig.
[Samuel Giddins](https://github.com/segiddins)
## 0.39.0 (2015-10-09) ## 0.39.0 (2015-10-09)
......
...@@ -18,6 +18,7 @@ gem 'json', :git => 'https://github.com/segiddins/json.git', :branch => 'seg-1.7 ...@@ -18,6 +18,7 @@ gem 'json', :git => 'https://github.com/segiddins/json.git', :branch => 'seg-1.7
group :development do group :development do
cp_gem 'claide', 'CLAide' cp_gem 'claide', 'CLAide'
cp_gem 'cocoapods-core', 'Core' cp_gem 'cocoapods-core', 'Core'
cp_gem 'cocoapods-deintegrate', 'cocoapods-deintegrate'
cp_gem 'cocoapods-downloader', 'cocoapods-downloader' cp_gem 'cocoapods-downloader', 'cocoapods-downloader'
cp_gem 'cocoapods-plugins', 'cocoapods-plugins' cp_gem 'cocoapods-plugins', 'cocoapods-plugins'
cp_gem 'cocoapods-search', 'cocoapods-search' cp_gem 'cocoapods-search', 'cocoapods-search'
......
GIT GIT
remote: https://github.com/CocoaPods/CLAide.git remote: https://github.com/CocoaPods/CLAide.git
revision: b44534d04023fbe82182a8be33d5c728f74c1b9c revision: 4ded02e52c34d5bbe5f6f031d917394286445aa6
branch: master branch: master
specs: specs:
claide (0.9.1) claide (0.9.1)
...@@ -24,7 +24,7 @@ GIT ...@@ -24,7 +24,7 @@ GIT
GIT GIT
remote: https://github.com/CocoaPods/Xcodeproj.git remote: https://github.com/CocoaPods/Xcodeproj.git
revision: ad8f6b78e424c274b63ff42ff6ad72840cb307a6 revision: eea8f8d58eef635f2cc9121ee1af6a5478a2841c
branch: master branch: master
specs: specs:
xcodeproj (0.28.2) xcodeproj (0.28.2)
...@@ -32,6 +32,13 @@ GIT ...@@ -32,6 +32,13 @@ GIT
claide (~> 0.9.1) claide (~> 0.9.1)
colored (~> 1.2) colored (~> 1.2)
GIT
remote: https://github.com/CocoaPods/cocoapods-deintegrate.git
revision: 7fa96ce9ccd9bda7e289a485111649f842189df6
branch: master
specs:
cocoapods-deintegrate (0.2.1)
GIT GIT
remote: https://github.com/CocoaPods/cocoapods-downloader.git remote: https://github.com/CocoaPods/cocoapods-downloader.git
revision: b35c7514683d8a5e3118d5333c15f941d40004fd revision: b35c7514683d8a5e3118d5333c15f941d40004fd
...@@ -91,6 +98,7 @@ PATH ...@@ -91,6 +98,7 @@ PATH
activesupport (>= 4.0.2) activesupport (>= 4.0.2)
claide (~> 0.9.1) claide (~> 0.9.1)
cocoapods-core (= 0.39.0) cocoapods-core (= 0.39.0)
cocoapods-deintegrate (~> 0.2.1)
cocoapods-downloader (~> 0.9.3) cocoapods-downloader (~> 0.9.3)
cocoapods-plugins (~> 0.4.2) cocoapods-plugins (~> 0.4.2)
cocoapods-search (~> 0.1.0) cocoapods-search (~> 0.1.0)
...@@ -146,7 +154,7 @@ GEM ...@@ -146,7 +154,7 @@ GEM
rb-kqueue (>= 0.2) rb-kqueue (>= 0.2)
metaclass (0.0.4) metaclass (0.0.4)
method_source (0.8.2) method_source (0.8.2)
minitest (5.8.2) minitest (5.8.3)
mocha (1.1.0) mocha (1.1.0)
metaclass (~> 0.0.1) metaclass (~> 0.0.1)
mocha-on-bacon (0.2.2) mocha-on-bacon (0.2.2)
...@@ -204,6 +212,7 @@ DEPENDENCIES ...@@ -204,6 +212,7 @@ DEPENDENCIES
clintegracon clintegracon
cocoapods! cocoapods!
cocoapods-core! cocoapods-core!
cocoapods-deintegrate!
cocoapods-dependencies cocoapods-dependencies
cocoapods-downloader! cocoapods-downloader!
cocoapods-plugins! cocoapods-plugins!
......
...@@ -28,15 +28,17 @@ Gem::Specification.new do |s| ...@@ -28,15 +28,17 @@ Gem::Specification.new do |s|
# Link with the version of CocoaPods-Core # Link with the version of CocoaPods-Core
s.add_runtime_dependency 'cocoapods-core', "= #{Pod::VERSION}" s.add_runtime_dependency 'cocoapods-core', "= #{Pod::VERSION}"
s.add_runtime_dependency 'claide', '~> 0.9.1' s.add_runtime_dependency 'claide', '~> 0.9.1'
s.add_runtime_dependency 'xcodeproj', '~> 0.28.2' s.add_runtime_dependency 'cocoapods-deintegrate', '~> 0.2.1'
s.add_runtime_dependency 'cocoapods-downloader', '~> 0.9.3' s.add_runtime_dependency 'cocoapods-downloader', '~> 0.9.3'
s.add_runtime_dependency 'cocoapods-plugins', '~> 0.4.2' s.add_runtime_dependency 'cocoapods-plugins', '~> 0.4.2'
s.add_runtime_dependency 'cocoapods-search', '~> 0.1.0' s.add_runtime_dependency 'cocoapods-search', '~> 0.1.0'
s.add_runtime_dependency 'cocoapods-stats', '~> 0.6.2' s.add_runtime_dependency 'cocoapods-stats', '~> 0.6.2'
s.add_runtime_dependency 'cocoapods-try', '~> 0.5.1'
s.add_runtime_dependency 'cocoapods-trunk', '~> 0.6.4' s.add_runtime_dependency 'cocoapods-trunk', '~> 0.6.4'
s.add_runtime_dependency 'cocoapods-try', '~> 0.5.1'
s.add_runtime_dependency 'molinillo', '~> 0.4.0' s.add_runtime_dependency 'molinillo', '~> 0.4.0'
s.add_runtime_dependency 'xcodeproj', '~> 0.28.2'
s.add_runtime_dependency 'colored', '~> 1.2' s.add_runtime_dependency 'colored', '~> 1.2'
s.add_runtime_dependency 'escape', '~> 0.0.4' s.add_runtime_dependency 'escape', '~> 0.0.4'
......
...@@ -40,6 +40,7 @@ module Pod ...@@ -40,6 +40,7 @@ module Pod
autoload :AggregateTarget, 'cocoapods/target/aggregate_target' autoload :AggregateTarget, 'cocoapods/target/aggregate_target'
autoload :Command, 'cocoapods/command' autoload :Command, 'cocoapods/command'
autoload :Deintegrator, 'cocoapods_deintegrate'
autoload :Executable, 'cocoapods/executable' autoload :Executable, 'cocoapods/executable'
autoload :ExternalSources, 'cocoapods/external_sources' autoload :ExternalSources, 'cocoapods/external_sources'
autoload :Installer, 'cocoapods/installer' autoload :Installer, 'cocoapods/installer'
......
...@@ -121,6 +121,7 @@ module Pod ...@@ -121,6 +121,7 @@ module Pod
raise Informative, message raise Informative, message
end end
UI.message 'Preparing' do UI.message 'Preparing' do
deintegrate_if_different_major_version
sandbox.prepare sandbox.prepare
ensure_plugins_are_installed! ensure_plugins_are_installed!
Migrator.migrate(sandbox) Migrator.migrate(sandbox)
...@@ -486,6 +487,25 @@ module Pod ...@@ -486,6 +487,25 @@ module Pod
context.sources context.sources
end end
# Run the deintegrator against all projects in the installation root if the
# current CocoaPods major version part is different than the one in the
# lockfile.
#
# @return [void]
#
def deintegrate_if_different_major_version
return unless lockfile
return if lockfile.cocoapods_version.major == Version.create(VERSION).major
UI.section('Fully deintegrating due to major version update') do
projects = Pathname.glob(config.installation_root + '*.xcodeproj').map { |path| Xcodeproj::Project.open(path) }
deintegrator = Deintegrator.new
projects.sort.each do |project|
deintegrator.deintegrate_project(project)
project.save if project.dirty?
end
end
end
# Ensures that all plugins specified in the {#podfile} are loaded. # Ensures that all plugins specified in the {#podfile} are loaded.
# #
# @return [void] # @return [void]
......
...@@ -63,6 +63,7 @@ module Pod ...@@ -63,6 +63,7 @@ module Pod
integrate_user_targets integrate_user_targets
warn_about_empty_podfile warn_about_empty_podfile
warn_about_xcconfig_overrides warn_about_xcconfig_overrides
save_projects
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
...@@ -112,8 +113,42 @@ module Pod ...@@ -112,8 +113,42 @@ module Pod
# @return [void] # @return [void]
# #
def integrate_user_targets def integrate_user_targets
targets_to_integrate.sort_by(&:name).each do |target| target_integrators = targets_to_integrate.sort_by(&:name).map do |target|
TargetIntegrator.new(target).integrate! TargetIntegrator.new(target)
end
Config.instance.with_changes(:silent => true) do
deintegrator = Deintegrator.new
all_project_targets = user_projects.flat_map(&:native_targets).uniq
all_native_targets = targets_to_integrate.flat_map(&:user_targets).uniq
targets_to_deintegrate = all_project_targets - all_native_targets
targets_to_deintegrate.each do |target|
deintegrator.deintegrate_target(target)
end
end
target_integrators.each(&:integrate!)
end
# Save all user projects.
#
# @return [void]
#
def save_projects
user_projects.each do |project|
if project.dirty?
project.save
else
# There is a bug in Xcode where the process of deleting and
# re-creating the xcconfig files used in the build
# configuration cause building the user project to fail until
# Xcode is relaunched.
#
# Touching/saving the project causes Xcode to reload these.
#
# https://github.com/CocoaPods/CocoaPods/issues/2665
FileUtils.touch(project.path + 'project.pbxproj')
end
end end
end end
...@@ -194,6 +229,10 @@ module Pod ...@@ -194,6 +229,10 @@ module Pod
targets.map(&:user_project_path).compact.uniq targets.map(&:user_project_path).compact.uniq
end end
def user_projects
targets.map(&:user_project).compact.uniq
end
def targets_to_integrate def targets_to_integrate
targets.reject { |target| target.target_definition.empty? } targets.reject { |target| target.target_definition.empty? }
end end
......
...@@ -38,34 +38,15 @@ module Pod ...@@ -38,34 +38,15 @@ module Pod
# #
def integrate! def integrate!
UI.section(integration_message) do UI.section(integration_message) do
# TODO: refactor into Xcodeproj https://github.com/CocoaPods/Xcodeproj/issues/202 XCConfigIntegrator.integrate(target, native_targets)
project_is_dirty = [ update_to_cocoapods_0_34
XCConfigIntegrator.integrate(target, native_targets), update_to_cocoapods_0_37_1
update_to_cocoapods_0_34, update_to_cocoapods_0_39
update_to_cocoapods_0_37_1,
update_to_cocoapods_0_39,
unless native_targets_to_integrate.empty?
add_pods_library add_pods_library
add_embed_frameworks_script_phase add_embed_frameworks_script_phase
add_copy_resources_script_phase add_copy_resources_script_phase
add_check_manifest_lock_script_phase add_check_manifest_lock_script_phase
true
end,
].any?
if project_is_dirty
user_project.save
else
# There is a bug in Xcode where the process of deleting and
# re-creating the xcconfig files used in the build
# configuration cause building the user project to fail until
# Xcode is relaunched.
#
# Touching/saving the project causes Xcode to reload these.
#
# https://github.com/CocoaPods/CocoaPods/issues/2665
FileUtils.touch(user_project.path + 'project.pbxproj')
end
end end
end end
...@@ -95,14 +76,11 @@ module Pod ...@@ -95,14 +76,11 @@ module Pod
script_path = target.copy_resources_script_relative_path script_path = target.copy_resources_script_relative_path
shell_script = %("#{script_path}"\n) shell_script = %("#{script_path}"\n)
changes = false
phases.each do |phase| phases.each do |phase|
unless phase.shell_script == shell_script unless phase.shell_script == shell_script
phase.shell_script = shell_script phase.shell_script = shell_script
changes = true
end end
end end
changes
end end
# Removes the embed frameworks phase for target types. # Removes the embed frameworks phase for target types.
...@@ -122,22 +100,16 @@ module Pod ...@@ -122,22 +100,16 @@ module Pod
# Adds the embed frameworks script when integrating as a static library. # Adds the embed frameworks script when integrating as a static library.
# #
# @return [Bool] whether any changes to the project were made.
#
# @todo This can be removed for CocoaPods 1.0 # @todo This can be removed for CocoaPods 1.0
# #
def update_to_cocoapods_0_39 def update_to_cocoapods_0_39
targets_to_embed = native_targets.select do |target| targets_to_embed = native_targets.select do |target|
EMBED_FRAMEWORK_TARGET_TYPES.include?(target.symbol_type) EMBED_FRAMEWORK_TARGET_TYPES.include?(target.symbol_type)
end end
requires_update = targets_to_embed.any? do |target|
!target.shell_script_build_phases.find { |bp| bp.name == EMBED_FRAMEWORK_PHASE_NAME }
end
if requires_update
targets_to_embed.each do |native_target| targets_to_embed.each do |native_target|
add_embed_frameworks_script_phase_to_target(native_target) add_embed_frameworks_script_phase_to_target(native_target)
end end
end
frameworks = user_project.frameworks_group frameworks = user_project.frameworks_group
native_targets.each do |native_target| native_targets.each do |native_target|
...@@ -151,12 +123,9 @@ module Pod ...@@ -151,12 +123,9 @@ module Pod
build_file.settings['ATTRIBUTES'].is_a?(Array) && build_file.settings['ATTRIBUTES'].is_a?(Array) &&
build_file.settings['ATTRIBUTES'].include?('Weak') build_file.settings['ATTRIBUTES'].include?('Weak')
build_file.settings = nil build_file.settings = nil
requires_update = true
end end
end end
end end
requires_update
end end
# Adds spec product reference to the frameworks build phase of the # Adds spec product reference to the frameworks build phase of the
...@@ -168,7 +137,7 @@ module Pod ...@@ -168,7 +137,7 @@ module Pod
# #
def add_pods_library def add_pods_library
frameworks = user_project.frameworks_group frameworks = user_project.frameworks_group
native_targets_to_integrate.each do |native_target| native_targets.each do |native_target|
build_phase = native_target.frameworks_build_phase build_phase = native_target.frameworks_build_phase
# Find and delete possible reference for the other product type # Find and delete possible reference for the other product type
...@@ -209,13 +178,10 @@ module Pod ...@@ -209,13 +178,10 @@ module Pod
# #
# @param [PBXNativeTarget] native_target # @param [PBXNativeTarget] native_target
# #
# @return [Bool] whether any changes to the project were made.
#
def remove_embed_frameworks_script_phase(native_target) def remove_embed_frameworks_script_phase(native_target)
embed_build_phase = native_target.shell_script_build_phases.find { |bp| bp.name == EMBED_FRAMEWORK_PHASE_NAME } embed_build_phase = native_target.shell_script_build_phases.find { |bp| bp.name == EMBED_FRAMEWORK_PHASE_NAME }
return false unless embed_build_phase.present? return unless embed_build_phase.present?
native_target.build_phases.delete(embed_build_phase) native_target.build_phases.delete(embed_build_phase)
true
end end
# Adds a shell script build phase responsible to copy the resources # Adds a shell script build phase responsible to copy the resources
...@@ -226,7 +192,7 @@ module Pod ...@@ -226,7 +192,7 @@ module Pod
# #
def add_copy_resources_script_phase def add_copy_resources_script_phase
phase_name = 'Copy Pods Resources' phase_name = 'Copy Pods Resources'
native_targets_to_integrate.each do |native_target| native_targets.each do |native_target|
phase = create_or_update_build_phase(native_target, phase_name) phase = create_or_update_build_phase(native_target, phase_name)
script_path = target.copy_resources_script_relative_path script_path = target.copy_resources_script_relative_path
phase.shell_script = %("#{script_path}"\n) phase.shell_script = %("#{script_path}"\n)
...@@ -244,9 +210,9 @@ module Pod ...@@ -244,9 +210,9 @@ module Pod
# #
def add_check_manifest_lock_script_phase def add_check_manifest_lock_script_phase
phase_name = 'Check Pods Manifest.lock' phase_name = 'Check Pods Manifest.lock'
native_targets_to_integrate.each do |native_target| native_targets.each do |native_target|
phase = create_or_update_build_phase(native_target, phase_name) phase = create_or_update_build_phase(native_target, phase_name)
native_target.build_phases.unshift(phase).uniq! native_target.build_phases.unshift(phase).uniq! unless native_target.build_phases.first == phase
phase.shell_script = <<-SH.strip_heredoc phase.shell_script = <<-SH.strip_heredoc
diff "${PODS_ROOT}/../Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null diff "${PODS_ROOT}/../Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null
if [[ $? != 0 ]] ; then if [[ $? != 0 ]] ; then
...@@ -261,7 +227,7 @@ module Pod ...@@ -261,7 +227,7 @@ module Pod
private private
# @!group Private helpers # @!group Private Helpers
#---------------------------------------------------------------------# #---------------------------------------------------------------------#
# @return [Array<PBXNativeTarget>] The list of all the targets that # @return [Array<PBXNativeTarget>] The list of all the targets that
...@@ -276,29 +242,11 @@ module Pod ...@@ -276,29 +242,11 @@ module Pod
# directory / product bundle. # directory / product bundle.
# #
def native_targets_to_embed_in def native_targets_to_embed_in
native_targets_to_integrate.select do |target| native_targets.select do |target|
EMBED_FRAMEWORK_TARGET_TYPES.include?(target.symbol_type) EMBED_FRAMEWORK_TARGET_TYPES.include?(target.symbol_type)
end end
end end
# @return [Array<PBXNativeTarget>] The list of the targets
# that have not been integrated by past installations
# of
#
def native_targets_to_integrate
unless @native_targets_to_integrate
@native_targets_to_integrate = native_targets.reject do |native_target|
native_target.frameworks_build_phase.files.any? do |build_file|
file_ref = build_file.file_ref
file_ref &&
file_ref.isa == 'PBXFileReference' &&
file_ref.display_name == target.product_name
end
end
end
@native_targets_to_integrate
end
# Read the project from the disk to ensure that it is up to date as # Read the project from the disk to ensure that it is up to date as
# other TargetIntegrators might have modified it. # other TargetIntegrators might have modified it.
# #
......
...@@ -15,17 +15,13 @@ module Pod ...@@ -15,17 +15,13 @@ module Pod
# The native targets associated which should be integrated # The native targets associated which should be integrated
# with the Pod bundle. # with the Pod bundle.
# #
# @return [Bool] whether any changes to the project were made.
#
def self.integrate(pod_bundle, targets) def self.integrate(pod_bundle, targets)
changes = false
targets.each do |target| targets.each do |target|
target.build_configurations.each do |config| target.build_configurations.each do |config|
changes = true if update_to_cocoapods_0_34(pod_bundle, targets) update_to_cocoapods_0_34(pod_bundle, targets)
changes = true if set_target_xcconfig(pod_bundle, target, config) set_target_xcconfig(pod_bundle, target, config)
end end
end end
changes
end end
private private
...@@ -42,13 +38,10 @@ module Pod ...@@ -42,13 +38,10 @@ module Pod
# @param [Array<XcodeProj::PBXNativeTarget>] targets # @param [Array<XcodeProj::PBXNativeTarget>] targets
# The native targets. # The native targets.
# #
# @return [Bool] whether any changes to the project were made.
#
# @todo This can be removed for CocoaPods 1.0 # @todo This can be removed for CocoaPods 1.0
# #
def self.update_to_cocoapods_0_34(pod_bundle, targets) def self.update_to_cocoapods_0_34(pod_bundle, targets)
sandbox = pod_bundle.sandbox sandbox = pod_bundle.sandbox
changes = false
targets.map(&:project).uniq.each do |project| targets.map(&:project).uniq.each do |project|
file_refs = project.files.select do |file_ref| file_refs = project.files.select do |file_ref|
path = file_ref.path.to_s path = file_ref.path.to_s
...@@ -64,10 +57,7 @@ module Pod ...@@ -64,10 +57,7 @@ module Pod
file_ref.remove_from_project file_ref.remove_from_project
end end
end end
changes = true unless file_refs.empty?
end end
changes
end end
# Creates a file reference to the xcconfig generated by # Creates a file reference to the xcconfig generated by
...@@ -83,15 +73,21 @@ module Pod ...@@ -83,15 +73,21 @@ module Pod
# @param [Xcodeproj::XCBuildConfiguration] config # @param [Xcodeproj::XCBuildConfiguration] config
# The build configuration. # The build configuration.
# #
# @return [Boolean] Indicates whether or not any changes were made.
#
def self.set_target_xcconfig(pod_bundle, target, config) def self.set_target_xcconfig(pod_bundle, target, config)
path = pod_bundle.xcconfig_relative_path(config.name) path = pod_bundle.xcconfig_relative_path(config.name)
group = config.project['Pods'] || config.project.new_group('Pods') group = config.project['Pods'] || config.project.new_group('Pods')
file_ref = group.files.find { |f| f.path == path } file_ref = group.files.find { |f| f.path == path }
if config.base_configuration_reference && existing = config.base_configuration_reference
config.base_configuration_reference != file_ref
unless xcconfig_includes_target_xcconfig?(config.base_configuration_reference, path) set_base_configuration_reference = ->() do
file_ref ||= group.new_file(path)
config.base_configuration_reference = file_ref
end
if existing && existing != file_ref
if existing.real_path.to_path.start_with?(pod_bundle.support_files_dir.to_path)
set_base_configuration_reference.call
elsif !xcconfig_includes_target_xcconfig?(config.base_configuration_reference, path)
UI.warn 'CocoaPods did not set the base configuration of your ' \ UI.warn 'CocoaPods did not set the base configuration of your ' \
'project because your project already has a custom ' \ 'project because your project already has a custom ' \
'config set. In order for CocoaPods integration to work at ' \ 'config set. In order for CocoaPods integration to work at ' \
...@@ -100,11 +96,8 @@ module Pod ...@@ -100,11 +96,8 @@ module Pod
'build configuration.' 'build configuration.'
end end
elsif config.base_configuration_reference.nil? || file_ref.nil? elsif config.base_configuration_reference.nil? || file_ref.nil?
file_ref ||= group.new_file(path) set_base_configuration_reference.call
config.base_configuration_reference = file_ref
return true
end end
false
end end
private private
......
Subproject commit 071e796206f4908dd57d06db496560d667c4020f Subproject commit 1ff4805c0df0187dd08ad1c61dfcbeee46631cd7
...@@ -5,7 +5,7 @@ module Pod ...@@ -5,7 +5,7 @@ module Pod
before do before do
project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject') project_path = SpecHelper.create_sample_app_copy_from_fixture('SampleProject')
@project = Xcodeproj::Project.open(project_path) @project = Xcodeproj::Project.open(project_path)
Xcodeproj::Project.new(config.sandbox.project_path).save Project.new(config.sandbox.project_path).save
@target = @project.targets.first @target = @project.targets.first
target_definition = Podfile::TargetDefinition.new('Pods', nil) target_definition = Podfile::TargetDefinition.new('Pods', nil)
target_definition.link_with_first_target = true target_definition.link_with_first_target = true
...@@ -105,5 +105,20 @@ module Pod ...@@ -105,5 +105,20 @@ module Pod
UI.warnings.should.not.match /not set.*base configuration/ UI.warnings.should.not.match /not set.*base configuration/
end end
it 'handles when xcconfig is set to another sandbox xcconfig' do
group = @project.new_group('Pods')
old_config = group.new_file('../Pods/Target Support Files/Pods/SampleConfig.xcconfig')
@target.build_configurations.each do |config|
config.base_configuration_reference = old_config
end
XCConfigIntegrator.integrate(@pod_bundle, [@target])
@target.build_configurations.each do |config|
config.base_configuration_reference.should.not == old_config
config.base_configuration_reference.path.should == @pod_bundle.xcconfig_relative_path(config.name)
end
UI.warnings.should.be.empty
end
end end
end end
...@@ -36,7 +36,6 @@ module Pod ...@@ -36,7 +36,6 @@ module Pod
end end
it 'allows the xcconfig integrator to edit already integrated targets if needed' do it 'allows the xcconfig integrator to edit already integrated targets if needed' do
@target_integrator.stubs(:native_targets_to_integrate).returns([])
TargetIntegrator::XCConfigIntegrator.expects(:integrate).with(@pod_bundle, [@target]) TargetIntegrator::XCConfigIntegrator.expects(:integrate).with(@pod_bundle, [@target])
@target_integrator.integrate! @target_integrator.integrate!
end end
...@@ -123,11 +122,10 @@ module Pod ...@@ -123,11 +122,10 @@ module Pod
it 'does not perform the integration if there are no targets to integrate' do it 'does not perform the integration if there are no targets to integrate' do
Installer::UserProjectIntegrator::TargetIntegrator::XCConfigIntegrator. Installer::UserProjectIntegrator::TargetIntegrator::XCConfigIntegrator.
integrate(@pod_bundle, @target_integrator.send(:native_targets)) integrate(@pod_bundle, @target_integrator.send(:native_targets))
@target_integrator.stubs(:native_targets_to_integrate).returns([]) @target_integrator.stubs(:native_targets).returns([])
@target_integrator.expects(:add_pods_library).never frameworks = @target_integrator.send(:user_project).frameworks_group.children
@target_integrator.expects(:add_copy_resources_script_phase).never
@target_integrator.send(:user_project).expects(:save).never
@target_integrator.integrate! @target_integrator.integrate!
@target_integrator.send(:user_project).frameworks_group.children.should == frameworks
end end
it 'adds an embed frameworks build phase if frameworks are used' do it 'adds an embed frameworks build phase if frameworks are used' do
...@@ -207,13 +205,6 @@ module Pod ...@@ -207,13 +205,6 @@ module Pod
@target_integrator.send(:native_targets).map(&:name).should == %w( SampleProject ) @target_integrator.send(:native_targets).map(&:name).should == %w( SampleProject )
end end
it 'returns the targets that need to be integrated' do
pods_library = @project.frameworks_group.new_product_ref_for_target('Pods', :static_library)
@target.frameworks_build_phase.add_file_reference(pods_library)
@project.save
@target_integrator.send(:native_targets_to_integrate).map(&:name).should.be.empty
end
it 'is robust against other types of references in the build files of the frameworks build phase' do it 'is robust against other types of references in the build files of the frameworks build phase' do
build_file = @project.new(Xcodeproj::Project::PBXBuildFile) build_file = @project.new(Xcodeproj::Project::PBXBuildFile)
build_file.file_ref = @project.new(Xcodeproj::Project::PBXVariantGroup) build_file.file_ref = @project.new(Xcodeproj::Project::PBXVariantGroup)
......
...@@ -14,7 +14,7 @@ module Pod ...@@ -14,7 +14,7 @@ module Pod
end end
end end
config.sandbox.project = Project.new(config.sandbox.project_path) config.sandbox.project = Project.new(config.sandbox.project_path)
Xcodeproj::Project.new(config.sandbox.project_path).save config.sandbox.project.save
@target = AggregateTarget.new(@podfile.target_definitions['Pods'], config.sandbox) @target = AggregateTarget.new(@podfile.target_definitions['Pods'], config.sandbox)
@target.client_root = sample_project_path.dirname @target.client_root = sample_project_path.dirname
@target.user_project = Xcodeproj::Project.open(@sample_project_path) @target.user_project = Xcodeproj::Project.open(@sample_project_path)
...@@ -52,6 +52,19 @@ module Pod ...@@ -52,6 +52,19 @@ module Pod
UI.warnings.should.include?('The Podfile does not contain any dependencies') UI.warnings.should.include?('The Podfile does not contain any dependencies')
end end
it 'deintegrates targets that are not associated with the podfile' do
additional_project = Xcodeproj::Project.new('Project.xcodeproj')
Deintegrator.any_instance.expects(:deintegrate_target).with additional_project.new_target(:application, 'Other App', :ios)
user_project = @target.user_project
user_project.native_targets.each do |target|
next if target.name == 'SampleProject'
Deintegrator.any_instance.expects(:deintegrate_target).with(target)
end
@integrator.stubs(:user_projects).returns([additional_project, user_project])
@integrator.send(:integrate_user_targets)
end
describe '#warn_about_xcconfig_overrides' do describe '#warn_about_xcconfig_overrides' do
shared 'warn_about_xcconfig_overrides' do shared 'warn_about_xcconfig_overrides' do
target_config = stub(:name => 'Release', :build_settings => @user_target_build_settings) target_config = stub(:name => 'Release', :build_settings => @user_target_build_settings)
...@@ -192,6 +205,30 @@ module Pod ...@@ -192,6 +205,30 @@ module Pod
@integrator.targets.map(&:name).should == ['Pods', 'Pods-empty'] @integrator.targets.map(&:name).should == ['Pods', 'Pods-empty']
@integrator.send(:targets_to_integrate).map(&:name).should == ['Pods'] @integrator.send(:targets_to_integrate).map(&:name).should == ['Pods']
end end
it 'skips saving projects that are not dirtied (but touches them instead)' do
project = mock('Project')
project.stubs(:path).returns(Pathname('project.xcodeproj'))
project.expects(:dirty?).returns(false)
project.expects(:save).never
@integrator.stubs(:user_projects).returns([project])
FileUtils.expects(:touch).with(project.path + 'project.pbxproj')
@integrator.send(:save_projects)
end
it 'saves projects that are dirty' do
project = mock('Project')
project.stubs(:path).returns(Pathname('project.xcodeproj'))
project.expects(:dirty?).returns(true)
project.expects(:save).once
@integrator.stubs(:user_projects).returns([project])
FileUtils.expects(:touch).never
@integrator.send(:save_projects)
end
end end
#-----------------------------------------------------------------------# #-----------------------------------------------------------------------#
......
...@@ -4,12 +4,12 @@ require 'cocoapods_stats/sender' ...@@ -4,12 +4,12 @@ require 'cocoapods_stats/sender'
# @return [Lockfile] # @return [Lockfile]
# #
def generate_lockfile def generate_lockfile(lockfile_version: Pod::VERSION)
hash = {} hash = {}
hash['PODS'] = [] hash['PODS'] = []
hash['DEPENDENCIES'] = [] hash['DEPENDENCIES'] = []
hash['SPEC CHECKSUMS'] = [] hash['SPEC CHECKSUMS'] = []
hash['COCOAPODS'] = Pod::VERSION hash['COCOAPODS'] = lockfile_version
Pod::Lockfile.new(hash) Pod::Lockfile.new(hash)
end end
...@@ -177,6 +177,38 @@ module Pod ...@@ -177,6 +177,38 @@ module Pod
end.message.should.match /should.*run.*outside.*Pods directory.*Current directory.*\./m end.message.should.match /should.*run.*outside.*Pods directory.*Current directory.*\./m
end end
end end
describe 'handling CocoaPods version updates' do
it 'does not deintegrate when there is no lockfile' do
installer = Pod::Installer.new(config.sandbox, generate_podfile, nil)
UI.expects(:section).never
installer.send(:deintegrate_if_different_major_version)
end
it 'does not deintegrate when the major version is the same' do
VERSION.stubs(:to_s).returns('1.1.0')
should_not_deintegrate = %w(1.0.0 1.0.1 1.1.0 1.2.2)
should_not_deintegrate.each do |version|
lockfile = generate_lockfile(:lockfile_version => version)
installer = Pod::Installer.new(config.sandbox, generate_podfile, lockfile)
Pathname.expects(:glob).never
installer.send(:deintegrate_if_different_major_version)
end
end
it 'does deintegrate when the major version is different' do
VERSION.stubs(:to_s).returns('1.1.0')
should_not_deintegrate = %w(0.39.0 2.0.0 10.0-beta)
should_not_deintegrate.each do |version|
lockfile = generate_lockfile(:lockfile_version => version)
installer = Pod::Installer.new(config.sandbox, generate_podfile, lockfile)
project = fixture('SampleProject/SampleProject.xcodeproj')
Pathname.expects(:glob).with(config.installation_root + '*.xcodeproj').returns([project])
Deintegrator.any_instance.expects(:deintegrate_project)
installer.send(:deintegrate_if_different_major_version)
end
end
end
end end
#-------------------------------------------------------------------------# #-------------------------------------------------------------------------#
......
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