Permalink
Browse files

Refactor

  • Loading branch information...
1 parent 419af92 commit 3ca4bf3d95a2dfa289115b2d542a3e19e7011ad8 @alloy alloy committed Sep 11, 2011
Showing with 19 additions and 26 deletions.
  1. +1 −2 lib/cocoa_pods/command/install.rb
  2. +15 −17 lib/cocoa_pods/specification.rb
  3. +3 −7 lib/cocoa_pods/xcode_project.rb
@@ -3,9 +3,8 @@ class Command
class Install < Command
def run
if spec = Specification.from_podfile(podfile)
- #config.clean = false
spec.install_dependent_specifications!
- spec.create_static_library!
+ spec.create_static_library_project!
else
$stderr.puts "No Podfile found in current working directory."
end
@@ -119,35 +119,33 @@ def install_dependent_specifications!
end
end
- def create_static_library!
- puts "==> Creating static library"
- source_files, frameworks, header_search_paths = [], [], []
+ def create_static_library_project!
+ puts "==> Creating static library project"
+ project = XcodeProject.static_library
resolved_dependent_specification_sets.each do |set|
# In case the set is only part of other pods we don't need to build
# the pod itself.
next if set.only_part_of_other_pod?
-
spec = set.podspec
+
spec.read(:source_files).each do |pattern|
pattern = spec.pod_destroot + pattern
pattern = pattern + '*.{h,m,mm,c,cpp}' if pattern.directory?
- source_files.concat(Dir.glob(pattern.to_s).map { |f| Pathname.new(f) })
- end
- if f = spec.read(:frameworks)
- frameworks.concat(f)
+ Dir.glob(pattern.to_s).each do |file|
+ file = Pathname.new(file)
+ file = file.relative_path_from(config.project_pods_root)
+ project.add_source_file(file)
+ 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
- project = XcodeProject.static_library
- source_files.each do |file|
- file = file.relative_path_from(config.project_pods_root)
- project.add_source_file(file)
+ if search_paths = spec.read(:header_search_paths)
+ search_paths.each { |path| project.add_header_search_path(path) }
+ end
end
- frameworks.each { |framework| project.add_framework(framework) }
- project.add_header_search_paths(header_search_paths)
project.create_in(config.project_pods_root)
end
@@ -69,11 +69,9 @@ def add_framework(path)
add_file_to_list('PBXFrameworksBuildPhase', build_file_uuid)
end
- def add_header_search_paths(paths)
- objects_by_isa('XCBuildConfiguration').each do |uuid, object|
- existing_paths = object['buildSettings']['HEADER_SEARCH_PATHS'] ||= []
- p paths
- existing_paths.concat(paths)
+ def add_header_search_path(path)
+ objects_by_isa('XCBuildConfiguration').each do |_, object|
+ (object['buildSettings']['HEADER_SEARCH_PATHS'] ||= []) << path
end
end
@@ -94,15 +92,13 @@ def create_in(pods_root)
def add_file_to_list(isa, build_file_uuid)
object_uuid, object = objects_by_isa(isa).first
object['files'] << build_file_uuid
- #objects[object_uuid] = object
end
def add_file_to_group(file_ref_uuid, name)
object_uuid, object = objects.find do |_, object|
object['isa'] == 'PBXGroup' && object['name'] == name
end
object['children'] << file_ref_uuid
- #objects[object_uuid] = object
end
def objects

0 comments on commit 3ca4bf3

Please sign in to comment.