Commit e04d1529 authored by Eloy Duran's avatar Eloy Duran

Only add $(BUILT_PRODUCTS_DIR)/Pods and $(BUILT_PRODUCTS_DIR)/Pods/PodName to the search paths.

parent 32ce2fea
......@@ -38,18 +38,8 @@ module Pod
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)
file = file.relative_path_from(config.project_pods_root)
(grouped_files[file.dirname.to_s] ||= []) << file
end
end
grouped_files
......@@ -71,17 +61,14 @@ module Pod
def generate_project
build_specification_sets.each do |set|
xcodeproj.add_group(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}\""}
xcconfig << { 'USER_HEADER_SEARCH_PATHS' => %{"$(BUILT_PRODUCTS_DIR)/Pods/#{set.name}"} }
xcodeproj.add_group(set.name)
grouped_source_files_for_spec(set.specification).each do |dir, files|
copy_phase_uuid = xcodeproj.add_copy_header_build_phase(set.name, dir)
files.each do |file|
xcodeproj.add_source_file(file, set.specification.name, phase_uuid)
xcodeproj.add_source_file(file, set.name, copy_phase_uuid)
end
end
#puts "#{grouped_source_files_for_spec(set.specification)}"
xcconfig << set.specification.xcconfig
end
end
......
......@@ -61,7 +61,7 @@ module Pod
# Working around a bug in Xcode 4.2 betas, remove this once the Xcode bug is fixed:
# https://github.com/alloy/cocoapods/issues/13
#add_file_to_list('PBXHeadersBuildPhase', build_file_uuid)
add_file_to_list('PBXCopyFilesBuildPhase', build_file_uuid) {|uuid, _| uuid == phase_uuid}
add_file_to_list('PBXCopyFilesBuildPhase', build_file_uuid, phase_uuid)
else
extra = compiler_flags ? {"settings" => { "COMPILER_FLAGS" => compiler_flags }} : {}
build_file_uuid = add_build_file(file_ref_uuid, extra)
......@@ -89,6 +89,7 @@ module Pod
@template.writeToFile(pbxproj.to_s, atomically:true)
end
# TODO add comments, or even constants, describing what these magic numbers are.
def add_copy_header_build_phase(name, path)
phase_uuid = add_object({
"isa" => "PBXCopyFilesBuildPhase",
......@@ -104,7 +105,11 @@ module Pod
object['buildPhases'] << phase_uuid
phase_uuid
end
def objects_by_isa(isa)
objects.select { |_, object| object['isa'] == isa }
end
private
def add_object(object)
......@@ -129,9 +134,15 @@ module Pod
}))
end
def add_file_to_list(isa, build_file_uuid, &condition)
isa_objects = objects_by_isa(isa)
object_uuid, object = (condition.nil? ? isa_objects.first : isa_objects.find(&condition))
# TODO refactor to create PBX object classes and make this take aither a uuid or a class instead of both.
def add_file_to_list(isa, build_file_uuid, phase_uuid = nil)
objects = objects_by_isa(isa)
_ = object = nil
if phase_uuid.nil?
_, object = objects.first
else
object = objects[phase_uuid]
end
object['files'] << build_file_uuid
end
......@@ -146,10 +157,6 @@ module Pod
@template['objects']
end
def objects_by_isa(isa)
objects.select { |_, object| object['isa'] == isa }
end
def generate_uuid
_uuid = CFUUIDCreate(nil)
uuid = CFUUIDCreateString(nil, _uuid)
......
......@@ -19,33 +19,39 @@ describe "Pod::Installer" do
['Classes'],
{ 'ASIHTTPRequest' => "Classes/*.{h,m}", 'Reachability' => "External/Reachability/*.{h,m}" },
{
"USER_HEADER_SEARCH_PATHS" => "$(BUILT_PRODUCTS_DIR)/Pods",
"USER_HEADER_SEARCH_PATHS" => '"$(BUILT_PRODUCTS_DIR)/Pods" ' \
'"$(BUILT_PRODUCTS_DIR)/Pods/ASIHTTPRequest" ' \
'"$(BUILT_PRODUCTS_DIR)/Pods/Reachability"',
"ALWAYS_SEARCH_USER_PATHS" => "YES",
"OTHER_LDFLAGS" => "-framework SystemConfiguration -framework CFNetwork " \
"-framework MobileCoreServices -l z.1"
}
],
#[
#'Reachability',
#["External/Reachability/*.h", "External/Reachability/*.m"],
#{ 'Reachability' => "External/Reachability/*.{h,m}", },
#{
#"USER_HEADER_SEARCH_PATHS" => "$(BUILT_PRODUCTS_DIR)/Pods",
#"ALWAYS_SEARCH_USER_PATHS" => "YES"
#}
#],
#[
#'ASIWebPageRequest',
#['**/ASIWebPageRequest.*'],
#{ 'ASIHTTPRequest' => "Classes/*.{h,m}", 'ASIWebPageRequest' => "Classes/ASIWebPageRequest/*.{h,m}", 'Reachability' => "External/Reachability/*.{h,m}" },
#{
#"USER_HEADER_SEARCH_PATHS" => "$(BUILT_PRODUCTS_DIR)/Pods",
#"ALWAYS_SEARCH_USER_PATHS" => "YES",
#"HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2",
#"OTHER_LDFLAGS" => "-l xml2.2.7.3 -framework SystemConfiguration " \
#"-framework CFNetwork -framework MobileCoreServices -l z.1"
#}
#],
[
'Reachability',
["External/Reachability/*.h", "External/Reachability/*.m"],
{ 'Reachability' => "External/Reachability/*.{h,m}", },
{
"USER_HEADER_SEARCH_PATHS" => '"$(BUILT_PRODUCTS_DIR)/Pods" ' \
'"$(BUILT_PRODUCTS_DIR)/Pods/Reachability"',
"ALWAYS_SEARCH_USER_PATHS" => "YES"
}
],
[
'ASIWebPageRequest',
['**/ASIWebPageRequest.*'],
{ 'ASIHTTPRequest' => "Classes/*.{h,m}", 'ASIWebPageRequest' => "Classes/ASIWebPageRequest/*.{h,m}", 'Reachability' => "External/Reachability/*.{h,m}" },
{
"USER_HEADER_SEARCH_PATHS" => '"$(BUILT_PRODUCTS_DIR)/Pods" ' \
'"$(BUILT_PRODUCTS_DIR)/Pods/ASIWebPageRequest" ' \
'"$(BUILT_PRODUCTS_DIR)/Pods/ASIHTTPRequest" ' \
'"$(BUILT_PRODUCTS_DIR)/Pods/Reachability"',
"ALWAYS_SEARCH_USER_PATHS" => "YES",
"HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2",
"OTHER_LDFLAGS" => "-l xml2.2.7.3 -framework SystemConfiguration " \
"-framework CFNetwork -framework MobileCoreServices -l z.1"
}
],
].each do |name, patterns, expected_patterns, xcconfig|
Pod::Source.reset!
Pod::Spec::Set.reset!
......
......@@ -59,7 +59,7 @@ describe "Pod::Xcode::Project" do
build_file_uuids = []
%w{ m mm c cpp }.each do |ext|
path = Pathname.new("path/to/file.#{ext}")
file_ref_uuid = @project.add_source_file(path, 'Pods', '-fno-obj-arc')
file_ref_uuid = @project.add_source_file(path, 'Pods', nil, '-fno-obj-arc')
@project.find_object({
'isa' => 'PBXBuildFile',
'fileRef' => file_ref_uuid,
......@@ -68,6 +68,18 @@ describe "Pod::Xcode::Project" do
end
end
it "creates a copy build header phase which will copy headers to a specified path" do
phase_uuid = @project.add_copy_header_build_phase("SomePod", "Path/To/Source")
@project.find_object({
'isa' => 'PBXCopyFilesBuildPhase',
'dstPath' => '$(PUBLIC_HEADERS_FOLDER_PATH)/Path/To/Source',
'name' => 'Copy SomePod Public Headers'
}).should.not == nil
_, target = @project.objects_by_isa('PBXNativeTarget').first
target['buildPhases'].should.include phase_uuid
end
it "adds a `h' file as a build file and adds it to the `headers build' phase list" do
@project.add_group('SomeGroup')
path = Pathname.new("path/to/file.h")
......
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