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 ...@@ -38,18 +38,8 @@ module Pod
pattern = spec.pod_destroot + pattern pattern = spec.pod_destroot + pattern
pattern = pattern + '*.{h,m,mm,c,cpp}' if pattern.directory? pattern = pattern + '*.{h,m,mm,c,cpp}' if pattern.directory?
pattern.glob.each do |file| pattern.glob.each do |file|
dir, _ = file.relative_path_from(spec.pod_destroot).split file = file.relative_path_from(config.project_pods_root)
dir = dir.to_s (grouped_files[file.dirname.to_s] ||= []) << file
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
end end
grouped_files grouped_files
...@@ -71,17 +61,14 @@ module Pod ...@@ -71,17 +61,14 @@ module Pod
def generate_project def generate_project
build_specification_sets.each do |set| build_specification_sets.each do |set|
xcodeproj.add_group(set.specification.name) xcconfig << { 'USER_HEADER_SEARCH_PATHS' => %{"$(BUILT_PRODUCTS_DIR)/Pods/#{set.name}"} }
xcconfig << {'USER_HEADER_SEARCH_PATHS' => "\"$(BUILT_PRODUCTS_DIR)/Pods/#{set.specification.name}\""} xcodeproj.add_group(set.name)
grouped_source_files_for_spec(set.specification).each do |path, files| grouped_source_files_for_spec(set.specification).each do |dir, files|
phase_uuid = xcodeproj.add_copy_header_build_phase(set.specification.name, path) copy_phase_uuid = xcodeproj.add_copy_header_build_phase(set.name, dir)
xcconfig << {'USER_HEADER_SEARCH_PATHS' => "\"$(BUILT_PRODUCTS_DIR)/Pods/#{path}\""}
files.each do |file| 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
end end
#puts "#{grouped_source_files_for_spec(set.specification)}"
xcconfig << set.specification.xcconfig xcconfig << set.specification.xcconfig
end end
end end
......
...@@ -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) {|uuid, _| uuid == phase_uuid} add_file_to_list('PBXCopyFilesBuildPhase', build_file_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,7 @@ module Pod ...@@ -89,6 +89,7 @@ module Pod
@template.writeToFile(pbxproj.to_s, atomically:true) @template.writeToFile(pbxproj.to_s, atomically:true)
end end
# TODO add comments, or even constants, describing what these magic numbers are.
def add_copy_header_build_phase(name, path) def add_copy_header_build_phase(name, path)
phase_uuid = add_object({ phase_uuid = add_object({
"isa" => "PBXCopyFilesBuildPhase", "isa" => "PBXCopyFilesBuildPhase",
...@@ -105,6 +106,10 @@ module Pod ...@@ -105,6 +106,10 @@ module Pod
phase_uuid phase_uuid
end end
def objects_by_isa(isa)
objects.select { |_, object| object['isa'] == isa }
end
private private
def add_object(object) def add_object(object)
...@@ -129,9 +134,15 @@ module Pod ...@@ -129,9 +134,15 @@ module Pod
})) }))
end end
def add_file_to_list(isa, build_file_uuid, &condition) # TODO refactor to create PBX object classes and make this take aither a uuid or a class instead of both.
isa_objects = objects_by_isa(isa) def add_file_to_list(isa, build_file_uuid, phase_uuid = nil)
object_uuid, object = (condition.nil? ? isa_objects.first : isa_objects.find(&condition)) 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 object['files'] << build_file_uuid
end end
...@@ -146,10 +157,6 @@ module Pod ...@@ -146,10 +157,6 @@ module Pod
@template['objects'] @template['objects']
end end
def objects_by_isa(isa)
objects.select { |_, object| object['isa'] == isa }
end
def generate_uuid def generate_uuid
_uuid = CFUUIDCreate(nil) _uuid = CFUUIDCreate(nil)
uuid = CFUUIDCreateString(nil, _uuid) uuid = CFUUIDCreateString(nil, _uuid)
......
...@@ -19,33 +19,39 @@ describe "Pod::Installer" do ...@@ -19,33 +19,39 @@ describe "Pod::Installer" do
['Classes'], ['Classes'],
{ 'ASIHTTPRequest' => "Classes/*.{h,m}", 'Reachability' => "External/Reachability/*.{h,m}" }, { '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", "ALWAYS_SEARCH_USER_PATHS" => "YES",
"OTHER_LDFLAGS" => "-framework SystemConfiguration -framework CFNetwork " \ "OTHER_LDFLAGS" => "-framework SystemConfiguration -framework CFNetwork " \
"-framework MobileCoreServices -l z.1" "-framework MobileCoreServices -l z.1"
} }
], ],
#[ [
#'Reachability', 'Reachability',
#["External/Reachability/*.h", "External/Reachability/*.m"], ["External/Reachability/*.h", "External/Reachability/*.m"],
#{ 'Reachability' => "External/Reachability/*.{h,m}", }, { 'Reachability' => "External/Reachability/*.{h,m}", },
#{ {
#"USER_HEADER_SEARCH_PATHS" => "$(BUILT_PRODUCTS_DIR)/Pods", "USER_HEADER_SEARCH_PATHS" => '"$(BUILT_PRODUCTS_DIR)/Pods" ' \
#"ALWAYS_SEARCH_USER_PATHS" => "YES" '"$(BUILT_PRODUCTS_DIR)/Pods/Reachability"',
#} "ALWAYS_SEARCH_USER_PATHS" => "YES"
#], }
#[ ],
#'ASIWebPageRequest', [
#['**/ASIWebPageRequest.*'], 'ASIWebPageRequest',
#{ 'ASIHTTPRequest' => "Classes/*.{h,m}", 'ASIWebPageRequest' => "Classes/ASIWebPageRequest/*.{h,m}", 'Reachability' => "External/Reachability/*.{h,m}" }, ['**/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", "USER_HEADER_SEARCH_PATHS" => '"$(BUILT_PRODUCTS_DIR)/Pods" ' \
#"HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2", '"$(BUILT_PRODUCTS_DIR)/Pods/ASIWebPageRequest" ' \
#"OTHER_LDFLAGS" => "-l xml2.2.7.3 -framework SystemConfiguration " \ '"$(BUILT_PRODUCTS_DIR)/Pods/ASIHTTPRequest" ' \
#"-framework CFNetwork -framework MobileCoreServices -l z.1" '"$(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| ].each do |name, patterns, expected_patterns, xcconfig|
Pod::Source.reset! Pod::Source.reset!
Pod::Spec::Set.reset! Pod::Spec::Set.reset!
......
...@@ -59,7 +59,7 @@ describe "Pod::Xcode::Project" do ...@@ -59,7 +59,7 @@ describe "Pod::Xcode::Project" do
build_file_uuids = [] build_file_uuids = []
%w{ m mm c cpp }.each do |ext| %w{ m mm c cpp }.each do |ext|
path = Pathname.new("path/to/file.#{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({ @project.find_object({
'isa' => 'PBXBuildFile', 'isa' => 'PBXBuildFile',
'fileRef' => file_ref_uuid, 'fileRef' => file_ref_uuid,
...@@ -68,6 +68,18 @@ describe "Pod::Xcode::Project" do ...@@ -68,6 +68,18 @@ describe "Pod::Xcode::Project" do
end end
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 it "adds a `h' file as a build file and adds it to the `headers build' phase list" do
@project.add_group('SomeGroup') @project.add_group('SomeGroup')
path = Pathname.new("path/to/file.h") 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