Commit cd31ff83 authored by Joshua Weinberg's avatar Joshua Weinberg Committed by Eloy Duran

In progress work to close Issue 14, the directory structure is now preserved for…

In progress work to close Issue 14, the directory structure is now preserved for headers being copied in, need to update specs to match
parent cddcbad9
...@@ -32,6 +32,29 @@ module Pod ...@@ -32,6 +32,29 @@ module Pod
source_files source_files
end end
def grouped_source_files_for_spec(spec)
grouped_files = {}
spec.source_files.each do |pattern|
pattern = spec.pod_destroot + pattern
pattern = pattern + '*.{h,m,mm,c,cpp}' if pattern.directory?
pattern.glob.each do |file|
dir, _ = file.relative_path_from(spec.pod_destroot).split
dir = dir.to_s
if dir == "."
dir = spec.name
else
if dir.split('/')[0] != spec.name
dir = spec.name + '/' + dir
end
end
grouped_files[dir.to_s] ||= []
grouped_files[dir.to_s] << file.relative_path_from(config.project_pods_root)
end
end
grouped_files
end
def xcconfig def xcconfig
@xcconfig ||= Xcode::Config.new({ @xcconfig ||= Xcode::Config.new({
# In a workspace this is where the static library headers should be found # In a workspace this is where the static library headers should be found
...@@ -47,15 +70,19 @@ module Pod ...@@ -47,15 +70,19 @@ module Pod
end end
def generate_project def generate_project
source_files.each do |group, files|
xcodeproj.add_group(group)
files.each do |file|
xcodeproj.add_source_file(file, group)
end
end
build_specification_sets.each do |set| build_specification_sets.each do |set|
xcconfig << set.specification.xcconfig xcodeproj.add_group(set.specification.name)
xcconfig << {'USER_HEADER_SEARCH_PATHS' => "\"$(BUILT_PRODUCTS_DIR)/Pods/#{set.specification.name}\""} xcconfig << {'USER_HEADER_SEARCH_PATHS' => "\"$(BUILT_PRODUCTS_DIR)/Pods/#{set.specification.name}\""}
grouped_source_files_for_spec(set.specification).each do |path, files|
phase_uuid = xcodeproj.add_copy_header_build_phase(set.specification.name, path)
xcconfig << {'USER_HEADER_SEARCH_PATHS' => "\"$(BUILT_PRODUCTS_DIR)/Pods/#{path}\""}
files.each do |file|
xcodeproj.add_source_file(file, set.specification.name, phase_uuid)
end
end
#puts "#{grouped_source_files_for_spec(set.specification)}"
xcconfig << set.specification.xcconfig
end end
end end
......
...@@ -53,7 +53,7 @@ module Pod ...@@ -53,7 +53,7 @@ module Pod
source_files source_files
end end
def add_source_file(file, group, compiler_flags = nil) def add_source_file(file, group, phase_uuid = nil, compiler_flags = nil)
file_ref_uuid = add_file_reference(file, 'SOURCE_ROOT') file_ref_uuid = add_file_reference(file, 'SOURCE_ROOT')
add_object_to_group(file_ref_uuid, group) add_object_to_group(file_ref_uuid, group)
if file.extname == '.h' if file.extname == '.h'
...@@ -61,7 +61,7 @@ module Pod ...@@ -61,7 +61,7 @@ module Pod
# Working around a bug in Xcode 4.2 betas, remove this once the Xcode bug is fixed: # Working around a bug in Xcode 4.2 betas, remove this once the Xcode bug is fixed:
# https://github.com/alloy/cocoapods/issues/13 # https://github.com/alloy/cocoapods/issues/13
#add_file_to_list('PBXHeadersBuildPhase', build_file_uuid) #add_file_to_list('PBXHeadersBuildPhase', build_file_uuid)
add_file_to_list('PBXCopyFilesBuildPhase', build_file_uuid, group) add_file_to_list('PBXCopyFilesBuildPhase', build_file_uuid, lambda {|uuid, _| uuid == phase_uuid})
else else
extra = compiler_flags ? {"settings" => { "COMPILER_FLAGS" => compiler_flags }} : {} extra = compiler_flags ? {"settings" => { "COMPILER_FLAGS" => compiler_flags }} : {}
build_file_uuid = add_build_file(file_ref_uuid, extra) build_file_uuid = add_build_file(file_ref_uuid, extra)
...@@ -89,6 +89,22 @@ module Pod ...@@ -89,6 +89,22 @@ module Pod
@template.writeToFile(pbxproj.to_s, atomically:true) @template.writeToFile(pbxproj.to_s, atomically:true)
end end
def add_copy_header_build_phase(name, path)
phase_uuid = add_object({
"isa" => "PBXCopyFilesBuildPhase",
"buildActionMask" => "2147483647",
"dstPath" => "$(PUBLIC_HEADERS_FOLDER_PATH)/#{path}",
"dstSubfolderSpec" => "16",
"files" => [],
"name" => "Copy #{name} Public Headers",
"runOnlyForDeploymentPostprocessing" => "0",
})
object_uuid, object = objects_by_isa('PBXNativeTarget').first
object['buildPhases'] << phase_uuid
phase_uuid
end
private private
def add_object(object) def add_object(object)
...@@ -112,27 +128,12 @@ module Pod ...@@ -112,27 +128,12 @@ module Pod
"fileRef" => file_ref_uuid "fileRef" => file_ref_uuid
})) }))
end end
def add_copy_header_build_phase(name)
phase_uuid = add_object({
"isa" => "PBXCopyFilesBuildPhase",
"buildActionMask" => "2147483647",
"dstPath" => "$(PUBLIC_HEADERS_FOLDER_PATH)/#{name}",
"dstSubfolderSpec" => "16",
"files" => [],
"name" => "Copy #{name} Public Headers",
"runOnlyForDeploymentPostprocessing" => "0",
})
object_uuid, object = objects_by_isa('PBXNativeTarget').first
object['buildPhases'] << phase_uuid
end
def add_file_to_list(isa, build_file_uuid, name = nil) def add_file_to_list(isa, build_file_uuid, condition = nil)
isa_objects = objects_by_isa(isa) isa_objects = objects_by_isa(isa)
object_uuid, object = isa_objects.first object_uuid, object = isa_objects.first
if name != nil if condition != nil
object_uuid, object = isa_objects.select { |_, object| object['name'].include? name }.first object_uuid, object = isa_objects.select { |uuid, object| condition.call(uuid, object) }.first
end end
object['files'] << build_file_uuid object['files'] << build_file_uuid
......
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