Commit ff27eacf authored by Kevin Coleman's avatar Kevin Coleman

Recursively processes dependent frameworks to ensure all vendored frameworks are…

Recursively processes dependent frameworks to ensure all vendored frameworks are added to the targets xcconfig
parent 05eea37a
...@@ -43,7 +43,6 @@ module Pod ...@@ -43,7 +43,6 @@ module Pod
target_search_paths = target.build_headers.search_paths(target.platform) target_search_paths = target.build_headers.search_paths(target.platform)
sandbox_search_paths = target.sandbox.public_headers.search_paths(target.platform) sandbox_search_paths = target.sandbox.public_headers.search_paths(target.platform)
search_paths = target_search_paths.concat(sandbox_search_paths).uniq search_paths = target_search_paths.concat(sandbox_search_paths).uniq
framework_search_paths = target.dependent_targets.flat_map(&:file_accessors).flat_map(&:vendored_frameworks).map { |fw| '${PODS_ROOT}/' << fw.dirname.relative_path_from(target.sandbox.root).to_s }
config = { config = {
'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target), 'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target),
...@@ -51,7 +50,7 @@ module Pod ...@@ -51,7 +50,7 @@ module Pod
'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(search_paths), 'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(search_paths),
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1', 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
'SKIP_INSTALL' => 'YES', 'SKIP_INSTALL' => 'YES',
'FRAMEWORK_SEARCH_PATHS' => '$(inherited) ' << XCConfigHelper.quote(framework_search_paths) 'FRAMEWORK_SEARCH_PATHS' => '$(inherited) '
# 'USE_HEADERMAP' => 'NO' # 'USE_HEADERMAP' => 'NO'
} }
......
...@@ -50,6 +50,14 @@ module Pod ...@@ -50,6 +50,14 @@ module Pod
# The xcconfig to edit. # The xcconfig to edit.
# #
def self.add_settings_for_file_accessors_of_target(target, xcconfig) def self.add_settings_for_file_accessors_of_target(target, xcconfig)
# Recursively process all dependent targets to ensure dependency vendored
# frameworks and libraries are added to OTHER_LDFLAGS and FRAMEWORK_SEARCH_PATHS.
if target.host_requires_frameworks?
target.dependent_targets.each do |dependent_target|
add_settings_for_file_accessors_of_target(dependent_target, xcconfig)
end
end
target.file_accessors.each do |file_accessor| target.file_accessors.each do |file_accessor|
XCConfigHelper.add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, xcconfig) XCConfigHelper.add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, xcconfig)
file_accessor.vendored_frameworks.each do |vendored_framework| file_accessor.vendored_frameworks.each do |vendored_framework|
...@@ -91,7 +99,7 @@ module Pod ...@@ -91,7 +99,7 @@ module Pod
# #
def self.add_framework_build_settings(framework_path, xcconfig, sandbox_root) def self.add_framework_build_settings(framework_path, xcconfig, sandbox_root)
name = File.basename(framework_path, '.framework') name = File.basename(framework_path, '.framework')
dirname = '$(PODS_ROOT)/' + framework_path.dirname.relative_path_from(sandbox_root).to_s dirname = '${PODS_ROOT}/' + framework_path.dirname.relative_path_from(sandbox_root).to_s
build_settings = { build_settings = {
'OTHER_LDFLAGS' => "-framework #{name}", 'OTHER_LDFLAGS' => "-framework #{name}",
'FRAMEWORK_SEARCH_PATHS' => quote([dirname]), 'FRAMEWORK_SEARCH_PATHS' => quote([dirname]),
...@@ -113,7 +121,7 @@ module Pod ...@@ -113,7 +121,7 @@ module Pod
# #
def self.add_library_build_settings(library_path, xcconfig, sandbox_root) def self.add_library_build_settings(library_path, xcconfig, sandbox_root)
name = File.basename(library_path, '.a').sub(/\Alib/, '') name = File.basename(library_path, '.a').sub(/\Alib/, '')
dirname = '$(PODS_ROOT)/' + library_path.dirname.relative_path_from(sandbox_root).to_s dirname = '${PODS_ROOT}/' + library_path.dirname.relative_path_from(sandbox_root).to_s
build_settings = { build_settings = {
'OTHER_LDFLAGS' => "-l#{name}", 'OTHER_LDFLAGS' => "-l#{name}",
'LIBRARY_SEARCH_PATHS' => '$(inherited) ' + quote([dirname]), 'LIBRARY_SEARCH_PATHS' => '$(inherited) ' + quote([dirname]),
......
...@@ -8,5 +8,6 @@ Pod::Spec.new do |s| ...@@ -8,5 +8,6 @@ Pod::Spec.new do |s|
s.source = { :git => "http://monkey.local/monkey.git", :tag => s.version.to_s } s.source = { :git => "http://monkey.local/monkey.git", :tag => s.version.to_s }
s.license = 'MIT' s.license = 'MIT'
s.vendored_library = 'monkey.a' s.vendored_library = 'monkey.a'
#s.ios.vendored_framework = "monkey.framework"
s.public_header_files = 'monkey.h' s.public_header_files = 'monkey.h'
end end
...@@ -6,8 +6,15 @@ module Pod ...@@ -6,8 +6,15 @@ module Pod
describe PodXCConfig do describe PodXCConfig do
describe 'in general' do describe 'in general' do
before do before do
@monkey_spec = fixture_spec('monkey/monkey.podspec')
@monkey_spec.vendored_framework = 'monkey.framework'
@monkey_pod_target = fixture_pod_target(@monkey_spec)
@spec = fixture_spec('banana-lib/BananaLib.podspec') @spec = fixture_spec('banana-lib/BananaLib.podspec')
@pod_target = fixture_pod_target(@spec) @pod_target = fixture_pod_target(@spec)
@pod_target.dependent_targets = [@monkey_pod_target]
@pod_target.host_requires_frameworks = true
@consumer = @pod_target.spec_consumers.first @consumer = @pod_target.spec_consumers.first
@podfile = @pod_target.podfile @podfile = @pod_target.podfile
@generator = PodXCConfig.new(@pod_target) @generator = PodXCConfig.new(@pod_target)
...@@ -18,8 +25,6 @@ module Pod ...@@ -18,8 +25,6 @@ module Pod
@spec.weak_frameworks = ['iAd'] @spec.weak_frameworks = ['iAd']
@spec.libraries = ['xml2'] @spec.libraries = ['xml2']
file_accessors = [Sandbox::FileAccessor.new(fixture('banana-lib'), @consumer)] file_accessors = [Sandbox::FileAccessor.new(fixture('banana-lib'), @consumer)]
# vendored_framework_paths = [config.sandbox.root + 'BananaLib/BananaLib.framework']
# Sandbox::FileAccessor.any_instance.stubs(:vendored_frameworks).returns(vendored_framework_paths)
@pod_target.stubs(:file_accessors).returns(file_accessors) @pod_target.stubs(:file_accessors).returns(file_accessors)
...@@ -47,6 +52,10 @@ module Pod ...@@ -47,6 +52,10 @@ module Pod
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include('-weak_framework "iAd"') @xcconfig.to_hash['OTHER_LDFLAGS'].should.include('-weak_framework "iAd"')
end end
it 'includes the vendored dynamic frameworks for dependecy pods of the specification' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include('-framework "monkey"')
end
it 'does not configure the project to load all members that implement Objective-c classes or categories from the static library' do it 'does not configure the project to load all members that implement Objective-c classes or categories from the static library' do
@xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include '-ObjC' @xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include '-ObjC'
end end
......
...@@ -127,7 +127,7 @@ module Pod ...@@ -127,7 +127,7 @@ module Pod
@sut.add_framework_build_settings(framework_path, xcconfig, config.sandbox.root) @sut.add_framework_build_settings(framework_path, xcconfig, config.sandbox.root)
hash_config = xcconfig.to_hash hash_config = xcconfig.to_hash
hash_config['OTHER_LDFLAGS'].should == '-framework "Parse"' hash_config['OTHER_LDFLAGS'].should == '-framework "Parse"'
hash_config['FRAMEWORK_SEARCH_PATHS'].should == '"$(PODS_ROOT)/Parse"' hash_config['FRAMEWORK_SEARCH_PATHS'].should == '"${PODS_ROOT}/Parse"'
end end
it "doesn't override existing linker flags" do it "doesn't override existing linker flags" do
...@@ -143,7 +143,7 @@ module Pod ...@@ -143,7 +143,7 @@ module Pod
xcconfig = Xcodeproj::Config.new('FRAMEWORK_SEARCH_PATHS' => '"path/to/frameworks"') xcconfig = Xcodeproj::Config.new('FRAMEWORK_SEARCH_PATHS' => '"path/to/frameworks"')
@sut.add_framework_build_settings(framework_path, xcconfig, config.sandbox.root) @sut.add_framework_build_settings(framework_path, xcconfig, config.sandbox.root)
hash_config = xcconfig.to_hash hash_config = xcconfig.to_hash
hash_config['FRAMEWORK_SEARCH_PATHS'].should == '"path/to/frameworks" "$(PODS_ROOT)/Parse"' hash_config['FRAMEWORK_SEARCH_PATHS'].should == '"path/to/frameworks" "${PODS_ROOT}/Parse"'
end end
end end
...@@ -156,7 +156,7 @@ module Pod ...@@ -156,7 +156,7 @@ module Pod
@sut.add_library_build_settings(path, xcconfig, config.sandbox.root) @sut.add_library_build_settings(path, xcconfig, config.sandbox.root)
hash_config = xcconfig.to_hash hash_config = xcconfig.to_hash
hash_config['OTHER_LDFLAGS'].should == '-l"Proj4"' hash_config['OTHER_LDFLAGS'].should == '-l"Proj4"'
hash_config['LIBRARY_SEARCH_PATHS'].should == '$(inherited) "$(PODS_ROOT)/MapBox/Proj4"' hash_config['LIBRARY_SEARCH_PATHS'].should == '$(inherited) "${PODS_ROOT}/MapBox/Proj4"'
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