Commit fa69d832 authored by Dieter Komendera's avatar Dieter Komendera

Instead of copying headers to BUILT_PRODUCTS_DIR symlink them into a defined dir…

Instead of copying headers to BUILT_PRODUCTS_DIR symlink them into a defined dir structure in Pods/Headers.
parent 93869040
......@@ -29,7 +29,7 @@ module Pod
def xcconfig
@xcconfig ||= Xcodeproj::Config.new({
# In a workspace this is where the static library headers should be found.
'HEADER_SEARCH_PATHS' => '"$(BUILT_PRODUCTS_DIR)/Pods"',
'HEADER_SEARCH_PATHS' => '"Pods/Headers"',
# This makes categories from static libraries work, which many libraries
# require, so we add these by default.
'OTHER_LDFLAGS' => '-ObjC -all_load',
......@@ -75,11 +75,18 @@ module Pod
"#{@definition.lib_name}-prefix.pch"
end
def headers_symlink_path_name
"Pods/Headers"
end
# TODO move xcconfig related code into the xcconfig method, like copy_resources_script and generate_bridge_support.
def install!
# First add the target to the project
@target = @project.targets.new_static_library(@definition.lib_name)
# Clean old header symlinks
FileUtils.rm_r(headers_symlink_path_name, :secure => true) if File.exists?(headers_symlink_path_name)
header_search_paths = []
build_specifications.each do |spec|
xcconfig.merge!(spec.xcconfig)
......@@ -87,12 +94,14 @@ module Pod
spec.implementation_files.each do |file|
@target.add_source_file(file, nil, spec.compiler_flags)
end
# Add header files to a `copy header build phase` for each destination
# directory in the pod's header directory.
# Symlink header files to Pods/Headers
spec.copy_header_mappings.each do |header_dir, files|
copy_phase = @target.copy_files_build_phases.new_pod_dir(spec.name, header_dir)
files.each do |file|
@target.add_source_file(file, copy_phase)
target_dir = "#{headers_symlink_path_name}/#{header_dir}"
FileUtils.mkdir_p(target_dir)
Dir.chdir(target_dir) do
files.each do |file|
FileUtils.ln_s("../../#{file}", file.basename)
end
end
end
# Collect all header search paths
......
......@@ -296,7 +296,7 @@ module Pod
# methods.
def header_search_paths
dirs = [header_dir] + copy_header_mappings.keys
dirs.map { |dir| %{"$(BUILT_PRODUCTS_DIR)/Pods/#{dir}"} }
dirs.map { |dir| %{"Pods/Headers/#{dir}"} }
end
def to_s
......
......@@ -10,7 +10,7 @@ describe "Pod::Installer" do
end
it "sets the header search paths where installed Pod headers can be found" do
@xcconfig['HEADER_SEARCH_PATHS'].should == '"$(BUILT_PRODUCTS_DIR)/Pods"'
@xcconfig['HEADER_SEARCH_PATHS'].should == '"Pods/Headers"'
@xcconfig['ALWAYS_SEARCH_USER_PATHS'].should == 'YES'
end
......
......@@ -209,8 +209,8 @@ describe "A Pod::Specification, with installed source," do
Pathname.new('ns') + from.basename
end
@spec.header_search_paths.should == %w{
"$(BUILT_PRODUCTS_DIR)/Pods/SSZipArchive"
"$(BUILT_PRODUCTS_DIR)/Pods/SSZipArchive/ns"
"Pods/Headers/SSZipArchive"
"Pods/Headers/SSZipArchive/ns"
}
end
......@@ -220,8 +220,8 @@ describe "A Pod::Specification, with installed source," do
Pathname.new('ns') + from.basename
end
@spec.header_search_paths.should == %w{
"$(BUILT_PRODUCTS_DIR)/Pods/AnotherRoot"
"$(BUILT_PRODUCTS_DIR)/Pods/AnotherRoot/ns"
"Pods/Headers/AnotherRoot"
"Pods/Headers/AnotherRoot/ns"
}
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