Commit a072f3e5 authored by Marius Rackwitz's avatar Marius Rackwitz

Fix duplicate symbol errors by mixed header imports

With static libraries and CocoaPods `#import "…"` and `#import <…>` could be used to import the local headers in "$PODS_ROOT/Headers/…". With frameworks the compiler automatically discovers public headers of the linked frameworks, so we have to ensure that we pass the `-iquote` flag for each framework pointing to its embedded headers. Otherwise this will led to errors because either the `#import "…" won't be discovered at all or they will be seen as different and the compiler will fail with duplicate symbols.
parent c5f93ced
...@@ -47,21 +47,32 @@ module Pod ...@@ -47,21 +47,32 @@ module Pod
# @return [Xcodeproj::Config] # @return [Xcodeproj::Config]
# #
def generate def generate
header_search_path_flags = target.sandbox.public_headers.search_paths(target.platform)
pod_targets = target.pod_targets_for_build_configuration(@configuration_name) pod_targets = target.pod_targets_for_build_configuration(@configuration_name)
config = { config = {
'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target), 'OTHER_LDFLAGS' => XCConfigHelper.default_ld_flags(target),
'OTHER_LIBTOOLFLAGS' => '$(OTHER_LDFLAGS)', 'OTHER_LIBTOOLFLAGS' => '$(OTHER_LDFLAGS)',
'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(header_search_path_flags),
'PODS_ROOT' => target.relative_pods_root, 'PODS_ROOT' => target.relative_pods_root,
'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1', 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) COCOAPODS=1',
'OTHER_CFLAGS' => '$(inherited) ' + XCConfigHelper.quote(header_search_path_flags, '-isystem')
} }
if target.requires_framework? if target.requires_framework?
# Framework headers are automatically discoverable by `#import <…>`.
header_search_paths = pod_targets.map { |target| "$PODS_FRAMEWORK_BUILD_PATH/#{target.product_name}/Headers" }
build_settings = { build_settings = {
'PODS_FRAMEWORK_BUILD_PATH' => target.configuration_build_dir, 'PODS_FRAMEWORK_BUILD_PATH' => target.configuration_build_dir,
'FRAMEWORK_SEARCH_PATHS' => '"$PODS_FRAMEWORK_BUILD_PATH"', 'FRAMEWORK_SEARCH_PATHS' => '"$PODS_FRAMEWORK_BUILD_PATH"',
# Make headers discoverable by `import "…"`
'OTHER_CFLAGS' => '$(inherited) ' + XCConfigHelper.quote(header_search_paths, '-iquote')
}
config.merge!(build_settings)
else
# Make headers discoverable from $PODS_ROOT/Headers directory
header_search_paths = target.sandbox.public_headers.search_paths(target.platform)
build_settings = {
# by `import "…"`
'HEADER_SEARCH_PATHS' => XCConfigHelper.quote(header_search_paths),
# by `#import <…>`
'OTHER_CFLAGS' => '$(inherited) ' + XCConfigHelper.quote(header_search_paths, '-isystem')
} }
config.merge!(build_settings) config.merge!(build_settings)
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