Skip to content

Commit

Permalink
Merge pull request #4544 from CocoaPods/seg-properly-integrate-all-ta…
Browse files Browse the repository at this point in the history
…rgets

Ensure all user projects are properly integrated
  • Loading branch information
segiddins committed Dec 4, 2015
2 parents 08bd4c9 + d14f40f commit 4c6ecd4
Show file tree
Hide file tree
Showing 14 changed files with 240 additions and 136 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,18 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Samuel Giddins](https://github.com/segiddins)
[#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

* Fix compiling of asset catalog files inside resource bundles.
Expand Down Expand Up @@ -158,6 +170,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Samuel Giddins](https://github.com/segiddins)
[#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)

Expand Down
21 changes: 11 additions & 10 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ gemspec
gem 'json', :git => 'https://github.com/segiddins/json.git', :branch => 'seg-1.7.7-ruby-2.2'

group :development do
cp_gem 'claide', 'CLAide'
cp_gem 'cocoapods-core', 'Core'
cp_gem 'cocoapods-downloader', 'cocoapods-downloader'
cp_gem 'cocoapods-plugins', 'cocoapods-plugins'
cp_gem 'cocoapods-search', 'cocoapods-search'
cp_gem 'cocoapods-stats', 'cocoapods-stats'
cp_gem 'cocoapods-trunk', 'cocoapods-trunk'
cp_gem 'cocoapods-try', 'cocoapods-try'
cp_gem 'molinillo', 'Molinillo'
cp_gem 'xcodeproj', 'Xcodeproj'
cp_gem 'claide', 'CLAide'
cp_gem 'cocoapods-core', 'Core'
cp_gem 'cocoapods-deintegrate', 'cocoapods-deintegrate'
cp_gem 'cocoapods-downloader', 'cocoapods-downloader'
cp_gem 'cocoapods-plugins', 'cocoapods-plugins'
cp_gem 'cocoapods-search', 'cocoapods-search'
cp_gem 'cocoapods-stats', 'cocoapods-stats'
cp_gem 'cocoapods-trunk', 'cocoapods-trunk'
cp_gem 'cocoapods-try', 'cocoapods-try'
cp_gem 'molinillo', 'Molinillo'
cp_gem 'xcodeproj', 'Xcodeproj'

gem 'cocoapods-dependencies'

Expand Down
15 changes: 12 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/CocoaPods/CLAide.git
revision: b44534d04023fbe82182a8be33d5c728f74c1b9c
revision: 4ded02e52c34d5bbe5f6f031d917394286445aa6
branch: master
specs:
claide (0.9.1)
Expand All @@ -24,14 +24,21 @@ GIT

GIT
remote: https://github.com/CocoaPods/Xcodeproj.git
revision: ad8f6b78e424c274b63ff42ff6ad72840cb307a6
revision: eea8f8d58eef635f2cc9121ee1af6a5478a2841c
branch: master
specs:
xcodeproj (0.28.2)
activesupport (>= 3)
claide (~> 0.9.1)
colored (~> 1.2)

GIT
remote: https://github.com/CocoaPods/cocoapods-deintegrate.git
revision: 7fa96ce9ccd9bda7e289a485111649f842189df6
branch: master
specs:
cocoapods-deintegrate (0.2.1)

GIT
remote: https://github.com/CocoaPods/cocoapods-downloader.git
revision: b35c7514683d8a5e3118d5333c15f941d40004fd
Expand Down Expand Up @@ -91,6 +98,7 @@ PATH
activesupport (>= 4.0.2)
claide (~> 0.9.1)
cocoapods-core (= 0.39.0)
cocoapods-deintegrate (~> 0.2.1)
cocoapods-downloader (~> 0.9.3)
cocoapods-plugins (~> 0.4.2)
cocoapods-search (~> 0.1.0)
Expand Down Expand Up @@ -146,7 +154,7 @@ GEM
rb-kqueue (>= 0.2)
metaclass (0.0.4)
method_source (0.8.2)
minitest (5.8.2)
minitest (5.8.3)
mocha (1.1.0)
metaclass (~> 0.0.1)
mocha-on-bacon (0.2.2)
Expand Down Expand Up @@ -204,6 +212,7 @@ DEPENDENCIES
clintegracon
cocoapods!
cocoapods-core!
cocoapods-deintegrate!
cocoapods-dependencies
cocoapods-downloader!
cocoapods-plugins!
Expand Down
22 changes: 12 additions & 10 deletions cocoapods.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ Gem::Specification.new do |s|
s.require_paths = %w{ lib }

# Link with the version of CocoaPods-Core
s.add_runtime_dependency 'cocoapods-core', "= #{Pod::VERSION}"
s.add_runtime_dependency 'claide', '~> 0.9.1'
s.add_runtime_dependency 'xcodeproj', '~> 0.28.2'
s.add_runtime_dependency 'cocoapods-downloader', '~> 0.9.3'
s.add_runtime_dependency 'cocoapods-plugins', '~> 0.4.2'
s.add_runtime_dependency 'cocoapods-search', '~> 0.1.0'
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 'molinillo', '~> 0.4.0'
s.add_runtime_dependency 'cocoapods-core', "= #{Pod::VERSION}"

s.add_runtime_dependency 'claide', '~> 0.9.1'
s.add_runtime_dependency 'cocoapods-deintegrate', '~> 0.2.1'
s.add_runtime_dependency 'cocoapods-downloader', '~> 0.9.3'
s.add_runtime_dependency 'cocoapods-plugins', '~> 0.4.2'
s.add_runtime_dependency 'cocoapods-search', '~> 0.1.0'
s.add_runtime_dependency 'cocoapods-stats', '~> 0.6.2'
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 'xcodeproj', '~> 0.28.2'

s.add_runtime_dependency 'colored', '~> 1.2'
s.add_runtime_dependency 'escape', '~> 0.0.4'
Expand Down
1 change: 1 addition & 0 deletions lib/cocoapods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def message

autoload :AggregateTarget, 'cocoapods/target/aggregate_target'
autoload :Command, 'cocoapods/command'
autoload :Deintegrator, 'cocoapods_deintegrate'
autoload :Executable, 'cocoapods/executable'
autoload :ExternalSources, 'cocoapods/external_sources'
autoload :Installer, 'cocoapods/installer'
Expand Down
20 changes: 20 additions & 0 deletions lib/cocoapods/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def prepare
raise Informative, message
end
UI.message 'Preparing' do
deintegrate_if_different_major_version
sandbox.prepare
ensure_plugins_are_installed!
Migrator.migrate(sandbox)
Expand Down Expand Up @@ -486,6 +487,25 @@ def run_source_provider_hooks
context.sources
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.
#
# @return [void]
Expand Down
43 changes: 41 additions & 2 deletions lib/cocoapods/installer/user_project_integrator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def integrate!
integrate_user_targets
warn_about_empty_podfile
warn_about_xcconfig_overrides
save_projects
end

#-----------------------------------------------------------------------#
Expand Down Expand Up @@ -112,8 +113,42 @@ def create_workspace
# @return [void]
#
def integrate_user_targets
targets_to_integrate.sort_by(&:name).each do |target|
TargetIntegrator.new(target).integrate!
target_integrators = targets_to_integrate.sort_by(&:name).map do |target|
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

Expand Down Expand Up @@ -194,6 +229,10 @@ def user_project_paths
targets.map(&:user_project_path).compact.uniq
end

def user_projects
targets.map(&:user_project).compact.uniq
end

def targets_to_integrate
targets.reject { |target| target.target_definition.empty? }
end
Expand Down
Loading

0 comments on commit 4c6ecd4

Please sign in to comment.