Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[CocoaPods/CocoaPods#904] Separate header paths for different targets…

… in .xcconfig files.
  • Loading branch information...
commit b22f34014801fb5ab974ac6111b34c17a5c1bf20 1 parent fe8342f
@michaelmelanson michaelmelanson authored
View
6 lib/cocoapods/generator/xcconfig/aggregate_xcconfig.rb
@@ -44,10 +44,12 @@ def save_as(path)
# @return [Xcodeproj::Config]
#
def generate
- header_search_path_flags = target.sandbox.public_headers.search_paths.map {|path| '-isystem'+path}
+ search_paths = target.sandbox.public_headers.search_paths(target.platform).uniq
+ header_search_path_flags = search_paths.map {|path| '-isystem'+path}
+
@xcconfig = Xcodeproj::Config.new({
'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target),
- 'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(target.sandbox.public_headers.search_paths),
+ 'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(search_paths),
'PODS_ROOT' => target.relative_pods_root,
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
'OTHER_CFLAGS' => '$(inherited) ' + XCConfigHelper.quote(header_search_path_flags)
View
5 lib/cocoapods/generator/xcconfig/private_pod_xcconfig.rb
@@ -47,7 +47,10 @@ def save_as(path)
# @return [Xcodeproj::Config]
#
def generate
- search_paths = target.build_headers.search_paths.concat(target.sandbox.public_headers.search_paths)
+ target_build_headers = target.build_headers.search_paths(target.platform)
+ sandbox_public_headers = target.sandbox.public_headers.search_paths(target.platform)
+
+ search_paths = target_build_headers.concat(sandbox_public_headers).uniq
config = {
'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target),
'PODS_ROOT' => '${SRCROOT}',
View
8 lib/cocoapods/installer/file_references_installer.rb
@@ -116,15 +116,15 @@ def link_headers
libraries.each do |library|
library.file_accessors.each do |file_accessor|
headers_sandbox = Pathname.new(file_accessor.spec.root.name)
- library.build_headers.add_search_path(headers_sandbox)
- sandbox.public_headers.add_search_path(headers_sandbox)
+ library.build_headers.add_search_path(headers_sandbox, library.platform)
+ sandbox.public_headers.add_search_path(headers_sandbox, library.platform)
header_mappings(headers_sandbox, file_accessor, file_accessor.headers).each do |namespaced_path, files|
- library.build_headers.add_files(namespaced_path, files)
+ library.build_headers.add_files(namespaced_path, files, library.platform)
end
header_mappings(headers_sandbox, file_accessor, file_accessor.public_headers).each do |namespaced_path, files|
- sandbox.public_headers.add_files(namespaced_path, files)
+ sandbox.public_headers.add_files(namespaced_path, files, library.platform)
end
end
end
View
2  lib/cocoapods/installer/target_installer/pod_target_installer.rb
@@ -93,7 +93,7 @@ def create_xcconfig_file
path = library.xcconfig_private_path
private_gen = Generator::XCConfig::PrivatePodXCConfig.new(library, public_gen.xcconfig)
- UI.message "- Generating private xcconfig file at #{UI.path(path)}" do
+ UI.message "- Generating private xcconfig file for #{library.label} at #{UI.path(path)}" do
private_gen.save_as(path)
xcconfig_file_ref = add_file_to_support_group(path)
View
19 lib/cocoapods/sandbox/headers_store.rb
@@ -25,15 +25,17 @@ def root
def initialize(sandbox, relative_path)
@sandbox = sandbox
@relative_path = relative_path
- @search_paths = [relative_path]
+ @search_paths = []
end
# @return [Array<String>] All the search paths of the header directory in
# xcconfig format. The paths are specified relative to the pods
# root with the `${PODS_ROOT}` variable.
#
- def search_paths
- @search_paths.uniq.map { |path| "${PODS_ROOT}/#{path}" }
+ def search_paths(platform)
+ platform_path_entries = @search_paths.select {|entry| entry[:platform] == platform }
+
+ ["${PODS_ROOT}/#{@relative_path}"] + platform_path_entries.uniq.map { |entry| "${PODS_ROOT}/#{entry[:path]}" }
end
# Removes the directory as it is regenerated from scratch during each
@@ -64,8 +66,8 @@ def implode!
#
# @return [Pathname]
#
- def add_files(namespace, relative_header_paths)
- add_search_path(namespace)
+ def add_files(namespace, relative_header_paths, platform)
+ add_search_path(namespace, platform)
namespaced_path = root + namespace
namespaced_path.mkpath unless File.exist?(namespaced_path)
@@ -84,10 +86,13 @@ def add_files(namespace, relative_header_paths)
# @param [Pathname] path
# the path tho add.
#
+ # @param [String] platform
+ # the platform the search path applies to
+ #
# @return [void]
#
- def add_search_path(path)
- @search_paths << Pathname.new(@relative_path) + path
+ def add_search_path(path, platform)
+ @search_paths << {:platform => platform, :path => (Pathname.new(@relative_path) + path) }
end
#-----------------------------------------------------------------------#
View
4 spec/unit/generator/xcconfig/aggregate_xcconfig_spec.rb
@@ -56,12 +56,12 @@ module XCConfig
end
it 'adds the sandbox public headers search paths to the xcconfig, with quotes, as header search paths' do
- expected = "\"#{config.sandbox.public_headers.search_paths.join('" "')}\""
+ expected = "\"#{config.sandbox.public_headers.search_paths(:ios).join('" "')}\""
@xcconfig.to_hash['HEADER_SEARCH_PATHS'].should == expected
end
it 'adds the sandbox public headers search paths to the xcconfig, with quotes, as system headers' do
- expected = "$(inherited) \"-isystem#{config.sandbox.public_headers.search_paths.join('" -isystem"')}\""
+ expected = "$(inherited) \"-isystem#{config.sandbox.public_headers.search_paths(:ios).join('" -isystem"')}\""
@xcconfig.to_hash['OTHER_CFLAGS'].should == expected
end
View
4 spec/unit/generator/xcconfig/private_pod_xcconfig_spec.rb
@@ -44,8 +44,8 @@ module XCConfig
end
it 'adds the library build headers and public headers search paths to the xcconfig, with quotes' do
- private_headers = "\"#{@pod_target.build_headers.search_paths.join('" "')}\""
- public_headers = "\"#{config.sandbox.public_headers.search_paths.join('" "')}\""
+ private_headers = "\"#{@pod_target.build_headers.search_paths(:ios).join('" "')}\""
+ public_headers = "\"#{config.sandbox.public_headers.search_paths(:ios).join('" "')}\""
@xcconfig.to_hash['HEADER_SEARCH_PATHS'].should.include private_headers
@xcconfig.to_hash['HEADER_SEARCH_PATHS'].should.include public_headers
end
View
1  spec/unit/installer/file_references_installer_spec.rb
@@ -6,6 +6,7 @@ module Pod
before do
@file_accessor = fixture_file_accessor('banana-lib/BananaLib.podspec')
@pod_target = PodTarget.new([], nil, config.sandbox)
+ @pod_target.stubs(:platform).returns(Platform.new(:ios, '6.0'))
@pod_target.file_accessors = [@file_accessor]
@project = Project.new(config.sandbox.project_path)
@project.add_pod_group('BananaLib', fixture('banana-lib'))
View
8 spec/unit/sandbox/headers_store_spec.rb
@@ -22,7 +22,7 @@ module Pod
relative_header_paths.each do |path|
File.open(@sandbox.root + path, "w") { |file| file.write('hello') }
end
- symlink_paths = @header_dir.add_files(namespace_path, relative_header_paths)
+ symlink_paths = @header_dir.add_files(namespace_path, relative_header_paths, :fake_platform)
symlink_paths.each do |path|
path.should.be.symlink
File.read(path).should == "hello"
@@ -39,12 +39,12 @@ module Pod
relative_header_paths.each do |path|
File.open(@sandbox.root + path, "w") { |file| file.write('hello') }
end
- @header_dir.add_files(namespace_path, relative_header_paths)
- @header_dir.search_paths.should.include("${PODS_ROOT}/Headers/ExampleLib")
+ @header_dir.add_files(namespace_path, relative_header_paths, :fake_platform)
+ @header_dir.search_paths(:fake_platform).should.include("${PODS_ROOT}/Headers/ExampleLib")
end
it 'always adds the Headers root to the header search paths' do
- @header_dir.search_paths.should.include("${PODS_ROOT}/Headers")
+ @header_dir.search_paths(:fake_platform).should.include("${PODS_ROOT}/Headers")
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.