Commit d897a371 authored by Fabio Pelosin's avatar Fabio Pelosin

[XCConfigIntegrator] Migrate old installations

parent d80a7386
...@@ -18,7 +18,7 @@ GIT ...@@ -18,7 +18,7 @@ GIT
GIT GIT
remote: https://github.com/CocoaPods/Xcodeproj.git remote: https://github.com/CocoaPods/Xcodeproj.git
revision: f835e6e1145812ac04ac4b658321c727c2967547 revision: f7e2a798464b7f4fce49379a748490a8ba83549a
branch: master branch: master
specs: specs:
xcodeproj (0.18.0) xcodeproj (0.18.0)
......
...@@ -19,9 +19,10 @@ ...@@ -19,9 +19,10 @@
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
118DF2C9405612B45655D94E /* Pods-AFNetworking Example.Release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AFNetworking Example.Release.xcconfig"; path = "Pods/Pods-AFNetworking Example.Release.xcconfig"; sourceTree = "<group>"; };
1BC0FB7006F49381520A8545 /* Pods-AFNetworking Example.Debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AFNetworking Example.Debug.xcconfig"; path = "Pods/Pods-AFNetworking Example.Debug.xcconfig"; sourceTree = "<group>"; };
6935B1E417A24F0E958977ED /* libPods-AFNetworking Example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AFNetworking Example.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 6935B1E417A24F0E958977ED /* libPods-AFNetworking Example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AFNetworking Example.a"; sourceTree = BUILT_PRODUCTS_DIR; };
B304CCE7177D58DD00F4FC85 /* adn.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = adn.cer; sourceTree = SOURCE_ROOT; }; B304CCE7177D58DD00F4FC85 /* adn.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = adn.cer; sourceTree = SOURCE_ROOT; };
E74E8E7AFD3F4DCF9FEAB5B4 /* Pods-AFNetworking Example.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AFNetworking Example.xcconfig"; path = "Pods/Pods-AFNetworking Example.xcconfig"; sourceTree = "<group>"; };
F8129BFB1591061B009BFE23 /* AFNetworking Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "AFNetworking Example.app"; sourceTree = BUILT_PRODUCTS_DIR; }; F8129BFB1591061B009BFE23 /* AFNetworking Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "AFNetworking Example.app"; sourceTree = BUILT_PRODUCTS_DIR; };
F8129BFF1591061B009BFE23 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; F8129BFF1591061B009BFE23 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
F8129C021591061B009BFE23 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; F8129C021591061B009BFE23 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
...@@ -60,7 +61,8 @@ ...@@ -60,7 +61,8 @@
F8129C051591061B009BFE23 /* Classes */, F8129C051591061B009BFE23 /* Classes */,
F8129BFE1591061B009BFE23 /* Frameworks */, F8129BFE1591061B009BFE23 /* Frameworks */,
F8129BFC1591061B009BFE23 /* Products */, F8129BFC1591061B009BFE23 /* Products */,
E74E8E7AFD3F4DCF9FEAB5B4 /* Pods-AFNetworking Example.xcconfig */, 1BC0FB7006F49381520A8545 /* Pods-AFNetworking Example.Debug.xcconfig */,
118DF2C9405612B45655D94E /* Pods-AFNetworking Example.Release.xcconfig */,
); );
indentWidth = 4; indentWidth = 4;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -296,7 +298,7 @@ ...@@ -296,7 +298,7 @@
}; };
F8129C1A1591061B009BFE23 /* Debug */ = { F8129C1A1591061B009BFE23 /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = E74E8E7AFD3F4DCF9FEAB5B4 /* Pods-AFNetworking Example.xcconfig */; baseConfigurationReference = 1BC0FB7006F49381520A8545 /* Pods-AFNetworking Example.Debug.xcconfig */;
buildSettings = { buildSettings = {
CODE_SIGN_IDENTITY = ""; CODE_SIGN_IDENTITY = "";
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
...@@ -310,7 +312,7 @@ ...@@ -310,7 +312,7 @@
}; };
F8129C1B1591061B009BFE23 /* Release */ = { F8129C1B1591061B009BFE23 /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = E74E8E7AFD3F4DCF9FEAB5B4 /* Pods-AFNetworking Example.xcconfig */; baseConfigurationReference = 118DF2C9405612B45655D94E /* Pods-AFNetworking Example.Release.xcconfig */;
buildSettings = { buildSettings = {
CODE_SIGN_IDENTITY = ""; CODE_SIGN_IDENTITY = "";
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
......
...@@ -35,8 +35,9 @@ ...@@ -35,8 +35,9 @@
/* Begin PBXFileReference section */ /* Begin PBXFileReference section */
2982AD3117107C0000FFF048 /* adn.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = adn.cer; sourceTree = SOURCE_ROOT; }; 2982AD3117107C0000FFF048 /* adn.cer */ = {isa = PBXFileReference; lastKnownFileType = file; path = adn.cer; sourceTree = SOURCE_ROOT; };
50ABD6EC159FC2CE001BE42C /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; }; 50ABD6EC159FC2CE001BE42C /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; };
7384432FCC95B62DB577C5D3 /* Pods-AFNetworking iOS Example.Release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AFNetworking iOS Example.Release.xcconfig"; path = "Pods/Pods-AFNetworking iOS Example.Release.xcconfig"; sourceTree = "<group>"; };
9D87F8FEDE4A4313B0D579A3 /* libPods-AFNetworking iOS Example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AFNetworking iOS Example.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 9D87F8FEDE4A4313B0D579A3 /* libPods-AFNetworking iOS Example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-AFNetworking iOS Example.a"; sourceTree = BUILT_PRODUCTS_DIR; };
AE3A9F4CC86440AAA3CF5792 /* Pods-AFNetworking iOS Example.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AFNetworking iOS Example.xcconfig"; path = "Pods/Pods-AFNetworking iOS Example.xcconfig"; sourceTree = "<group>"; }; B5BF8B2301C54A4C220FBB61 /* Pods-AFNetworking iOS Example.Debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-AFNetworking iOS Example.Debug.xcconfig"; path = "Pods/Pods-AFNetworking iOS Example.Debug.xcconfig"; sourceTree = "<group>"; };
F8129C3815910830009BFE23 /* Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = SOURCE_ROOT; }; F8129C3815910830009BFE23 /* Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = SOURCE_ROOT; };
F8129C7215910C37009BFE23 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = SOURCE_ROOT; }; F8129C7215910C37009BFE23 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = SOURCE_ROOT; };
F8129C7315910C37009BFE23 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = SOURCE_ROOT; }; F8129C7315910C37009BFE23 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = SOURCE_ROOT; };
...@@ -130,7 +131,8 @@ ...@@ -130,7 +131,8 @@
F8E469ED1395812A00DB05C8 /* Images */, F8E469ED1395812A00DB05C8 /* Images */,
F8E469631395739D00DB05C8 /* Frameworks */, F8E469631395739D00DB05C8 /* Frameworks */,
F8E469611395739C00DB05C8 /* Products */, F8E469611395739C00DB05C8 /* Products */,
AE3A9F4CC86440AAA3CF5792 /* Pods-AFNetworking iOS Example.xcconfig */, B5BF8B2301C54A4C220FBB61 /* Pods-AFNetworking iOS Example.Debug.xcconfig */,
7384432FCC95B62DB577C5D3 /* Pods-AFNetworking iOS Example.Release.xcconfig */,
); );
indentWidth = 4; indentWidth = 4;
sourceTree = "<group>"; sourceTree = "<group>";
...@@ -356,7 +358,7 @@ ...@@ -356,7 +358,7 @@
}; };
F8E469821395739D00DB05C8 /* Debug */ = { F8E469821395739D00DB05C8 /* Debug */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = AE3A9F4CC86440AAA3CF5792 /* Pods-AFNetworking iOS Example.xcconfig */; baseConfigurationReference = B5BF8B2301C54A4C220FBB61 /* Pods-AFNetworking iOS Example.Debug.xcconfig */;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_ARC = YES;
...@@ -378,7 +380,7 @@ ...@@ -378,7 +380,7 @@
}; };
F8E469831395739D00DB05C8 /* Release */ = { F8E469831395739D00DB05C8 /* Release */ = {
isa = XCBuildConfiguration; isa = XCBuildConfiguration;
baseConfigurationReference = AE3A9F4CC86440AAA3CF5792 /* Pods-AFNetworking iOS Example.xcconfig */; baseConfigurationReference = 7384432FCC95B62DB577C5D3 /* Pods-AFNetworking iOS Example.Release.xcconfig */;
buildSettings = { buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO; ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ENABLE_OBJC_ARC = YES; CLANG_ENABLE_OBJC_ARC = YES;
......
...@@ -33,7 +33,7 @@ module Pod ...@@ -33,7 +33,7 @@ module Pod
# #
def create_xcconfig_file def create_xcconfig_file
target.build_configurations.each do |configuration| target.build_configurations.each do |configuration|
path = library.xcconfig_path(configuration) path = library.xcconfig_path(configuration.name)
UI.message "- Generating #{configuration.name} xcconfig file at #{UI.path(path)}" do UI.message "- Generating #{configuration.name} xcconfig file at #{UI.path(path)}" do
gen = Generator::XCConfig::AggregateXCConfig.new(library, configuration.name) gen = Generator::XCConfig::AggregateXCConfig.new(library, configuration.name)
gen.save_as(path) gen.save_as(path)
......
...@@ -30,10 +30,11 @@ module Pod ...@@ -30,10 +30,11 @@ module Pod
def integrate! def integrate!
UI.section(integration_message) do UI.section(integration_message) do
XCConfigIntegrator.integrate(target, native_targets) XCConfigIntegrator.integrate(target, native_targets)
return if native_targets_to_integrate.empty? unless native_targets_to_integrate.empty?
add_pods_library add_pods_library
add_copy_resources_script_phase add_copy_resources_script_phase
add_check_manifest_lock_script_phase add_check_manifest_lock_script_phase
end
user_project.save user_project.save
end end
end end
......
...@@ -18,6 +18,7 @@ module Pod ...@@ -18,6 +18,7 @@ module Pod
def self.integrate(pod_bundle, targets) def self.integrate(pod_bundle, targets)
targets.each do |target| targets.each do |target|
target.build_configurations.each do |config| target.build_configurations.each do |config|
update_from_cocoapods_0_33_1(pod_bundle, targets)
set_target_xcconfig(pod_bundle, config) set_target_xcconfig(pod_bundle, config)
check_overrides(pod_bundle, target, config) check_overrides(pod_bundle, target, config)
end end
...@@ -29,6 +30,31 @@ module Pod ...@@ -29,6 +30,31 @@ module Pod
# @!group Integration steps # @!group Integration steps
#-------------------------------------------------------------------# #-------------------------------------------------------------------#
# Removes the xcconfig used up to CocoaPods 0.33 from the project and
# deletes the file it if exists.
#
# @param [Target::AggregateTarget] pod_bundle
# The Pods bundle.
#
# @param [XcodeProj::PBXNativeTarget] target
# The native targets.
#
# @todo This can be removed for CocoaPods 1.0
#
def self.update_from_cocoapods_0_33_1(pod_bundle, targets)
targets.map(&:project).uniq.each do |project|
path = pod_bundle.xcconfig_relative_path(nil)
file_ref = project.files.find { |f| f.path == path }
if file_ref
UI.message "- Removing (#{path})" do
file_ref.remove_from_project
absolute_path = pod_bundle.xcconfig_path
File.delete(absolute_path) if File.exist?(absolute_path)
end
end
end
end
# Creates a file reference to the xcconfig generated by # Creates a file reference to the xcconfig generated by
# CocoaPods (if needed) and sets it as the base configuration of # CocoaPods (if needed) and sets it as the base configuration of
# build configuration of the user target. # build configuration of the user target.
......
Subproject commit cd2f35e69c8bacf6bcff1af404d8702d4019f773 Subproject commit 40b03ee32f6f2d7935ee7bd7b0379ca550ad828c
...@@ -3,58 +3,69 @@ require File.expand_path('../../../../../spec_helper', __FILE__) ...@@ -3,58 +3,69 @@ require File.expand_path('../../../../../spec_helper', __FILE__)
module Pod module Pod
describe XCConfigIntegrator = Installer::UserProjectIntegrator::TargetIntegrator::XCConfigIntegrator do describe XCConfigIntegrator = Installer::UserProjectIntegrator::TargetIntegrator::XCConfigIntegrator do
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 Xcodeproj::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
@pod_bundle = AggregateTarget.new(target_definition, config.sandbox) @pod_bundle = AggregateTarget.new(target_definition, config.sandbox)
@pod_bundle.user_project_path = project_path @pod_bundle.user_project_path = project_path
@pod_bundle.client_root = project_path.dirname @pod_bundle.client_root = project_path.dirname
@pod_bundle.user_target_uuids = [@target.uuid] @pod_bundle.user_target_uuids = [@target.uuid]
configuration = Xcodeproj::Config.new({ configuration = Xcodeproj::Config.new({
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1' 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1'
}) })
@pod_bundle.xcconfigs['Debug'] = configuration @pod_bundle.xcconfigs['Debug'] = configuration
@pod_bundle.xcconfigs['Test'] = configuration @pod_bundle.xcconfigs['Test'] = configuration
@pod_bundle.xcconfigs['Release'] = configuration @pod_bundle.xcconfigs['Release'] = configuration
@pod_bundle.xcconfigs['App Store'] = configuration @pod_bundle.xcconfigs['App Store'] = configuration
end end
it 'sets the Pods xcconfig as the base config for each build configuration' do it 'cleans the xcconfig used up to CocoaPods 0.33.1' do
XCConfigIntegrator.integrate(@pod_bundle, [@target]) path = @pod_bundle.xcconfig_path
@target.build_configurations.each do |config| file_ref = @project.new_file(path)
xcconfig_file = @project.files.find { |f| f.path == @pod_bundle.xcconfig_relative_path(config) } config = @target.build_configuration_list['Release']
config.base_configuration_reference.should == xcconfig_file config.base_configuration_reference = file_ref
end File.expects(:exist?).returns(true)
end File.expects(:delete).with(path)
XCConfigIntegrator.integrate(@pod_bundle, [@target])
@project.files.find { |f| f.path == path }.should.be.nil
end
it 'does not duplicate the file reference to the CocoaPods xcconfig in the user project' do it 'sets the Pods xcconfig as the base config for each build configuration' do
path = @pod_bundle.xcconfig_relative_path('Release') XCConfigIntegrator.integrate(@pod_bundle, [@target])
existing = @project.new_file(path) @target.build_configurations.each do |config|
XCConfigIntegrator.integrate(@pod_bundle, [@target]) xcconfig_file = @project.files.find { |f| f.path == @pod_bundle.xcconfig_relative_path(config) }
config = @target.build_configuration_list['Release'] config.base_configuration_reference.should == xcconfig_file
config.base_configuration_reference.should.equal existing
end end
end
it 'check that the integrated target does not override the CocoaPods build settings' do it 'does not duplicate the file reference to the CocoaPods xcconfig in the user project' do
UI.warnings = '' path = @pod_bundle.xcconfig_relative_path('Release')
config = @target.build_configuration_list['Release'] existing = @project.new_file(path)
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = 'FLAG=1' XCConfigIntegrator.integrate(@pod_bundle, [@target])
XCConfigIntegrator.integrate(@pod_bundle, [@target]) config = @target.build_configuration_list['Release']
UI.warnings.should.include 'The `SampleProject [Release]` target ' \ config.base_configuration_reference.should.equal existing
'overrides the `GCC_PREPROCESSOR_DEFINITIONS` build setting' end
end
it 'allows build settings which inherit the settings form the CocoaPods xcconfig' do it 'check that the integrated target does not override the CocoaPods build settings' do
UI.warnings = '' UI.warnings = ''
config = @target.build_configuration_list['Release'] config = @target.build_configuration_list['Release']
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited)' config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = 'FLAG=1'
XCConfigIntegrator.integrate(@pod_bundle, [@target]) XCConfigIntegrator.integrate(@pod_bundle, [@target])
UI.warnings.should.not.include 'GCC_PREPROCESSOR_DEFINITIONS' UI.warnings.should.include 'The `SampleProject [Release]` target ' \
end 'overrides the `GCC_PREPROCESSOR_DEFINITIONS` build setting'
end
it 'allows build settings which inherit the settings form the CocoaPods xcconfig' do
UI.warnings = ''
config = @target.build_configuration_list['Release']
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = '$(inherited)'
XCConfigIntegrator.integrate(@pod_bundle, [@target])
UI.warnings.should.not.include 'GCC_PREPROCESSOR_DEFINITIONS'
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