Commit be41327f authored by Samuel E. Giddins's avatar Samuel E. Giddins

Merge pull request #4278 from layerhq/feature/vendored-dynamic-framework

[XCConfig Helper] Add dependency target vendored libs and frameworks to build settings.
parents fbeb7866 7383eb4f
......@@ -28,6 +28,10 @@ To install release candidates run `[sudo] gem install cocoapods --pre`
[Samuel Giddins](https://github.com/segiddins)
[#4124](https://github.com/CocoaPods/CocoaPods/issues/4124)
* Support for adding dependency target vendored libraries and frameworks to build settings.
[Kevin Coleman](https://github.com/kcoleman731)
[#4278](https://github.com/CocoaPods/CocoaPods/pull/4278)
##### Bug Fixes
* Give a meaningful message for the case where there is no available stable
......
......@@ -43,7 +43,6 @@ module Pod
target_search_paths = target.build_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
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 = {
'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target),
......@@ -51,7 +50,7 @@ module Pod
'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(search_paths),
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
'SKIP_INSTALL' => 'YES',
'FRAMEWORK_SEARCH_PATHS' => '$(inherited) ' << XCConfigHelper.quote(framework_search_paths)
'FRAMEWORK_SEARCH_PATHS' => '$(inherited) '
# 'USE_HEADERMAP' => 'NO'
}
......
......@@ -52,6 +52,26 @@ module Pod
def self.add_settings_for_file_accessors_of_target(target, xcconfig)
target.file_accessors.each do |file_accessor|
XCConfigHelper.add_spec_build_settings_to_xcconfig(file_accessor.spec_consumer, xcconfig)
end
XCConfigHelper.add_vendored_dependency_build_settings(target, xcconfig)
end
# Adds build settings for vendored frameworks and libraries.
#
# @param [PodTarget] target
# The pod target, which holds the list of +Spec::FileAccessor+.
#
# @param [Xcodeproj::Config] xcconfig
# The xcconfig to edit.
#
def self.add_vendored_dependency_build_settings(target, xcconfig)
if target.requires_frameworks?
target.dependent_targets.each do |dependent_target|
XCConfigHelper.add_vendored_dependency_build_settings(dependent_target, xcconfig)
end
end
target.file_accessors.each do |file_accessor|
file_accessor.vendored_frameworks.each do |vendored_framework|
XCConfigHelper.add_framework_build_settings(vendored_framework, xcconfig, target.sandbox.root)
end
......@@ -91,7 +111,7 @@ module Pod
#
def self.add_framework_build_settings(framework_path, xcconfig, sandbox_root)
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 = {
'OTHER_LDFLAGS' => "-framework #{name}",
'FRAMEWORK_SEARCH_PATHS' => quote([dirname]),
......@@ -113,7 +133,7 @@ module Pod
#
def self.add_library_build_settings(library_path, xcconfig, sandbox_root)
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 = {
'OTHER_LDFLAGS' => "-l#{name}",
'LIBRARY_SEARCH_PATHS' => '$(inherited) ' + quote([dirname]),
......
......@@ -6,8 +6,15 @@ module Pod
describe PodXCConfig do
describe 'in general' 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')
@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
@podfile = @pod_target.podfile
@generator = PodXCConfig.new(@pod_target)
......@@ -18,8 +25,6 @@ module Pod
@spec.weak_frameworks = ['iAd']
@spec.libraries = ['xml2']
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)
......@@ -47,6 +52,10 @@ module Pod
@xcconfig.to_hash['OTHER_LDFLAGS'].should.include('-weak_framework "iAd"')
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
@xcconfig.to_hash['OTHER_LDFLAGS'].should.not.include '-ObjC'
end
......
......@@ -127,7 +127,7 @@ module Pod
@sut.add_framework_build_settings(framework_path, xcconfig, config.sandbox.root)
hash_config = xcconfig.to_hash
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
it "doesn't override existing linker flags" do
......@@ -143,7 +143,7 @@ module Pod
xcconfig = Xcodeproj::Config.new('FRAMEWORK_SEARCH_PATHS' => '"path/to/frameworks"')
@sut.add_framework_build_settings(framework_path, xcconfig, config.sandbox.root)
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
......@@ -156,7 +156,7 @@ module Pod
@sut.add_library_build_settings(path, xcconfig, config.sandbox.root)
hash_config = xcconfig.to_hash
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
......
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