Commit 3ca4bf3d authored by Eloy Duran's avatar Eloy Duran

Refactor

parent 419af929
...@@ -3,9 +3,8 @@ module Pod ...@@ -3,9 +3,8 @@ module Pod
class Install < Command class Install < Command
def run def run
if spec = Specification.from_podfile(podfile) if spec = Specification.from_podfile(podfile)
#config.clean = false
spec.install_dependent_specifications! spec.install_dependent_specifications!
spec.create_static_library! spec.create_static_library_project!
else else
$stderr.puts "No Podfile found in current working directory." $stderr.puts "No Podfile found in current working directory."
end end
......
...@@ -119,35 +119,33 @@ module Pod ...@@ -119,35 +119,33 @@ module Pod
end end
end end
def create_static_library! def create_static_library_project!
puts "==> Creating static library" puts "==> Creating static library project"
source_files, frameworks, header_search_paths = [], [], [] project = XcodeProject.static_library
resolved_dependent_specification_sets.each do |set| resolved_dependent_specification_sets.each do |set|
# In case the set is only part of other pods we don't need to build # In case the set is only part of other pods we don't need to build
# the pod itself. # the pod itself.
next if set.only_part_of_other_pod? next if set.only_part_of_other_pod?
spec = set.podspec spec = set.podspec
spec.read(:source_files).each do |pattern| spec.read(:source_files).each do |pattern|
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?
source_files.concat(Dir.glob(pattern.to_s).map { |f| Pathname.new(f) }) Dir.glob(pattern.to_s).each do |file|
end file = Pathname.new(file)
if f = spec.read(:frameworks) file = file.relative_path_from(config.project_pods_root)
frameworks.concat(f) project.add_source_file(file)
end
end end
if s = spec.read(:header_search_paths)
header_search_paths.concat(s) if frameworks = spec.read(:frameworks)
frameworks.each { |framework| project.add_framework(framework) }
end end
end
project = XcodeProject.static_library if search_paths = spec.read(:header_search_paths)
source_files.each do |file| search_paths.each { |path| project.add_header_search_path(path) }
file = file.relative_path_from(config.project_pods_root) end
project.add_source_file(file)
end end
frameworks.each { |framework| project.add_framework(framework) }
project.add_header_search_paths(header_search_paths)
project.create_in(config.project_pods_root) project.create_in(config.project_pods_root)
end end
......
...@@ -69,11 +69,9 @@ module Pod ...@@ -69,11 +69,9 @@ module Pod
add_file_to_list('PBXFrameworksBuildPhase', build_file_uuid) add_file_to_list('PBXFrameworksBuildPhase', build_file_uuid)
end end
def add_header_search_paths(paths) def add_header_search_path(path)
objects_by_isa('XCBuildConfiguration').each do |uuid, object| objects_by_isa('XCBuildConfiguration').each do |_, object|
existing_paths = object['buildSettings']['HEADER_SEARCH_PATHS'] ||= [] (object['buildSettings']['HEADER_SEARCH_PATHS'] ||= []) << path
p paths
existing_paths.concat(paths)
end end
end end
...@@ -94,7 +92,6 @@ module Pod ...@@ -94,7 +92,6 @@ module Pod
def add_file_to_list(isa, build_file_uuid) def add_file_to_list(isa, build_file_uuid)
object_uuid, object = objects_by_isa(isa).first object_uuid, object = objects_by_isa(isa).first
object['files'] << build_file_uuid object['files'] << build_file_uuid
#objects[object_uuid] = object
end end
def add_file_to_group(file_ref_uuid, name) def add_file_to_group(file_ref_uuid, name)
...@@ -102,7 +99,6 @@ module Pod ...@@ -102,7 +99,6 @@ module Pod
object['isa'] == 'PBXGroup' && object['name'] == name object['isa'] == 'PBXGroup' && object['name'] == name
end end
object['children'] << file_ref_uuid object['children'] << file_ref_uuid
#objects[object_uuid] = object
end end
def objects def objects
......
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