cocoapods 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Pod
2
- VERSION = '0.3.8'
2
+ VERSION = '0.3.9'
3
3
 
4
4
  class Informative < StandardError
5
5
  end
@@ -46,7 +46,7 @@ module Pod
46
46
  end
47
47
 
48
48
  def add
49
- puts "==> Cloning spec repo `#{@name}' from `#{@url}'" unless config.silent?
49
+ puts "Cloning spec repo `#{@name}' from `#{@url}'" unless config.silent?
50
50
  config.repos_dir.mkpath
51
51
  Dir.chdir(config.repos_dir) { git("clone '#{@url}' #{@name}") }
52
52
  end
@@ -54,7 +54,7 @@ module Pod
54
54
  def update
55
55
  dirs = @name ? [dir] : config.repos_dir.children
56
56
  dirs.each do |dir|
57
- puts "==> Updating spec repo `#{dir.basename}'" unless config.silent?
57
+ puts "Updating spec repo `#{dir.basename}'" unless config.silent?
58
58
  Dir.chdir(dir) { git("pull") }
59
59
  end
60
60
  end
@@ -1,8 +1,6 @@
1
1
  module Pod
2
2
  module Generator
3
3
  class BridgeSupport
4
- include Config::Mixin
5
-
6
4
  extend Executable
7
5
  executable :gen_bridge_metadata
8
6
 
@@ -17,7 +15,6 @@ module Pod
17
15
  end
18
16
 
19
17
  def save_as(pathname)
20
- puts "==> Generating BridgeSupport metadata file at `#{pathname}'" unless config.silent?
21
18
  gen_bridge_metadata %{-c "#{search_paths.join(' ')}" -o '#{pathname}' '#{headers.join("' '")}'}
22
19
  end
23
20
  end
@@ -1,5 +1,7 @@
1
1
  module Pod
2
2
  class Installer
3
+ autoload :TargetInstaller, 'cocoapods/installer/target_installer'
4
+
3
5
  module Shared
4
6
  def dependent_specifications
5
7
  @dependent_specifications ||= Resolver.new(@podfile, @definition ? @definition.dependencies : nil).resolve
@@ -16,137 +18,6 @@ module Pod
16
18
  end
17
19
  end
18
20
 
19
- class TargetInstaller
20
- include Config::Mixin
21
- include Shared
22
-
23
- attr_reader :podfile, :project, :definition, :target
24
-
25
- def initialize(podfile, project, definition)
26
- @podfile, @project, @definition = podfile, project, definition
27
- end
28
-
29
- def xcconfig
30
- @xcconfig ||= Xcodeproj::Config.new({
31
- # In a workspace this is where the static library headers should be found.
32
- 'PODS_ROOT' => '"$(SRCROOT)/Pods"',
33
- 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers"',
34
- 'ALWAYS_SEARCH_USER_PATHS' => 'YES', # needed to make EmbedReader build
35
- # This makes categories from static libraries work, which many libraries
36
- # require, so we add these by default.
37
- 'OTHER_LDFLAGS' => '-ObjC -all_load',
38
- })
39
- end
40
-
41
- def xcconfig_filename
42
- "#{@definition.lib_name}.xcconfig"
43
- end
44
-
45
- def copy_resources_script
46
- @copy_resources_script ||= Generator::CopyResourcesScript.new(build_specifications.map do |spec|
47
- spec.expanded_resources
48
- end.flatten)
49
- end
50
-
51
- def copy_resources_filename
52
- "#{@definition.lib_name}-resources.sh"
53
- end
54
-
55
- def bridge_support_generator
56
- Generator::BridgeSupport.new(build_specifications.map do |spec|
57
- spec.header_files.map do |header|
58
- config.project_pods_root + header
59
- end
60
- end.flatten)
61
- end
62
-
63
- def bridge_support_filename
64
- "#{@definition.lib_name}.bridgesupport"
65
- end
66
-
67
- # TODO move out to Generator::PrefixHeader
68
- def save_prefix_header_as(pathname)
69
- pathname.open('w') do |header|
70
- header.puts "#ifdef __OBJC__"
71
- header.puts "#import #{@podfile.platform == :ios ? '<UIKit/UIKit.h>' : '<Cocoa/Cocoa.h>'}"
72
- header.puts "#endif"
73
- end
74
- end
75
-
76
- def prefix_header_filename
77
- "#{@definition.lib_name}-prefix.pch"
78
- end
79
-
80
- def headers_symlink_path_name
81
- "#{config.project_pods_root}/Headers"
82
- end
83
-
84
- # TODO move xcconfig related code into the xcconfig method, like copy_resources_script and generate_bridge_support.
85
- def install!
86
- # First add the target to the project
87
- @target = @project.targets.new_static_library(@definition.lib_name)
88
-
89
- # Clean old header symlinks
90
- FileUtils.rm_r(headers_symlink_path_name, :secure => true) if File.exists?(headers_symlink_path_name)
91
-
92
- header_search_paths = []
93
- build_specifications.each do |spec|
94
- xcconfig.merge!(spec.xcconfig)
95
- # Only add implementation files to the compile phase
96
- spec.implementation_files.each do |file|
97
- @target.add_source_file(file, nil, spec.compiler_flags)
98
- end
99
- # Symlink header files to Pods/Headers
100
- spec.copy_header_mappings.each do |header_dir, files|
101
- target_dir = "#{headers_symlink_path_name}/#{header_dir}"
102
- FileUtils.mkdir_p(target_dir)
103
- target_dir_real_path = Pathname.new(target_dir).realpath
104
- files.each do |file|
105
- source = Pathname.new("#{config.project_pods_root}/#{file}").realpath.relative_path_from(target_dir_real_path)
106
- Dir.chdir(target_dir) do
107
- FileUtils.ln_sf(source, File.basename(file))
108
- end
109
- end
110
- end
111
- # Collect all header search paths
112
- header_search_paths.concat(spec.header_search_paths)
113
- end
114
- xcconfig.merge!('HEADER_SEARCH_PATHS' => header_search_paths.sort.uniq.join(" "))
115
-
116
- # Now that we have added all the source files and copy header phases,
117
- # move the compile build phase to the end, so that headers are copied
118
- # to the build products dir first, and thus Pod source files can enjoy
119
- # the same namespacing of headers as the app would.
120
- @target.move_compile_phase_to_end!
121
-
122
- # Add all the target related support files to the group, even the copy
123
- # resources script although the project doesn't actually use them.
124
- support_files_group = @project.groups.find do |group|
125
- group.name == "Targets Support Files"
126
- end.groups.new("name" => @definition.lib_name)
127
- support_files_group.files.new('path' => copy_resources_filename)
128
- prefix_file = support_files_group.files.new('path' => prefix_header_filename)
129
- xcconfig_file = support_files_group.files.new("path" => xcconfig_filename)
130
- # Assign the xcconfig as the base config of each config.
131
- @target.buildConfigurations.each do |config|
132
- config.baseConfiguration = xcconfig_file
133
- config.buildSettings['OTHER_LDFLAGS'] = ''
134
- config.buildSettings['GCC_PREFIX_HEADER'] = prefix_header_filename
135
- config.buildSettings['PODS_ROOT'] = '$(SRCROOT)'
136
- end
137
- end
138
-
139
- def create_files_in(root)
140
- xcconfig.save_as(root + xcconfig_filename)
141
- if @podfile.generate_bridge_support?
142
- bridge_support_generator.save_as(root + bridge_support_filename)
143
- copy_resources_script.resources << bridge_support_filename
144
- end
145
- save_prefix_header_as(root + prefix_header_filename)
146
- copy_resources_script.save_as(root + copy_resources_filename)
147
- end
148
- end
149
-
150
21
  include Config::Mixin
151
22
  include Shared
152
23
 
@@ -182,28 +53,42 @@ module Pod
182
53
  end.compact
183
54
  end
184
55
 
56
+ def install_dependencies!
57
+ build_specifications.each do |spec|
58
+ if spec.pod_destroot.exist?
59
+ puts "Using #{spec}" unless config.silent?
60
+ else
61
+ puts "Installing #{spec}" unless config.silent?
62
+ spec = spec.part_of_specification if spec.part_of_other_pod?
63
+ downloader = Downloader.for_source(spec.pod_destroot, spec.source)
64
+ downloader.download
65
+ # TODO move cleaning into the installer as well
66
+ downloader.clean(spec.expanded_clean_paths) if config.clean
67
+ end
68
+ end
69
+ end
70
+
185
71
  def install!
186
- puts "Installing dependencies of: #{@podfile.defined_in_file}" unless config.silent?
187
- build_specifications.each(&:install!)
72
+ puts "Installing dependencies of: #{@podfile.defined_in_file}" if config.verbose?
73
+ install_dependencies!
188
74
  root = config.project_pods_root
189
75
 
190
- puts "==> Generating support files" unless config.silent?
76
+ puts "Generating support files" unless config.silent?
191
77
  target_installers.each do |target_installer|
192
78
  target_installer.install!
193
79
  target_installer.create_files_in(root)
194
80
  end
195
81
  generate_lock_file!
196
82
 
197
- puts "==> Running post install hooks" unless config.silent?
83
+ puts "* Running post install hooks" if config.verbose?
198
84
  # Post install hooks run _before_ saving of project, so that they can alter it before saving.
199
85
  target_installers.each do |target_installer|
200
86
  target_installer.build_specifications.each { |spec| spec.post_install(target_installer) }
201
87
  end
202
88
  @podfile.post_install!(self)
203
89
 
204
- puts "==> Generating Xcode project" unless config.silent?
205
90
  projpath = File.join(root, 'Pods.xcodeproj')
206
- puts " * Writing Xcode project file to `#{projpath}'" if config.verbose?
91
+ puts "* Writing Xcode project file to `#{projpath}'" if config.verbose?
207
92
  project.save_as(projpath)
208
93
  end
209
94
 
@@ -0,0 +1,139 @@
1
+ module Pod
2
+ class Installer
3
+ class TargetInstaller
4
+ include Config::Mixin
5
+ include Shared
6
+
7
+ attr_reader :podfile, :project, :definition, :target
8
+
9
+ def initialize(podfile, project, definition)
10
+ @podfile, @project, @definition = podfile, project, definition
11
+ end
12
+
13
+ def xcconfig
14
+ @xcconfig ||= Xcodeproj::Config.new({
15
+ # In a workspace this is where the static library headers should be found.
16
+ 'PODS_ROOT' => '$(SRCROOT)/Pods',
17
+ 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/Headers"',
18
+ 'ALWAYS_SEARCH_USER_PATHS' => 'YES', # needed to make EmbedReader build
19
+ # This makes categories from static libraries work, which many libraries
20
+ # require, so we add these by default.
21
+ 'OTHER_LDFLAGS' => '-ObjC -all_load',
22
+ })
23
+ end
24
+
25
+ def xcconfig_filename
26
+ "#{@definition.lib_name}.xcconfig"
27
+ end
28
+
29
+ def copy_resources_script
30
+ @copy_resources_script ||= Generator::CopyResourcesScript.new(build_specifications.map do |spec|
31
+ spec.expanded_resources
32
+ end.flatten)
33
+ end
34
+
35
+ def copy_resources_filename
36
+ "#{@definition.lib_name}-resources.sh"
37
+ end
38
+
39
+ def bridge_support_generator
40
+ Generator::BridgeSupport.new(build_specifications.map do |spec|
41
+ spec.header_files.map do |header|
42
+ config.project_pods_root + header
43
+ end
44
+ end.flatten)
45
+ end
46
+
47
+ def bridge_support_filename
48
+ "#{@definition.lib_name}.bridgesupport"
49
+ end
50
+
51
+ # TODO move out to Generator::PrefixHeader
52
+ def save_prefix_header_as(pathname)
53
+ pathname.open('w') do |header|
54
+ header.puts "#ifdef __OBJC__"
55
+ header.puts "#import #{@podfile.platform == :ios ? '<UIKit/UIKit.h>' : '<Cocoa/Cocoa.h>'}"
56
+ header.puts "#endif"
57
+ end
58
+ end
59
+
60
+ def prefix_header_filename
61
+ "#{@definition.lib_name}-prefix.pch"
62
+ end
63
+
64
+ def headers_symlink_path_name
65
+ "#{config.project_pods_root}/Headers"
66
+ end
67
+
68
+ # TODO move xcconfig related code into the xcconfig method, like copy_resources_script and generate_bridge_support.
69
+ def install!
70
+ # First add the target to the project
71
+ @target = @project.targets.new_static_library(@definition.lib_name)
72
+
73
+ # Clean old header symlinks
74
+ FileUtils.rm_r(headers_symlink_path_name, :secure => true) if File.exists?(headers_symlink_path_name)
75
+
76
+ header_search_paths = []
77
+ build_specifications.each do |spec|
78
+ xcconfig.merge!(spec.xcconfig)
79
+ # Only add implementation files to the compile phase
80
+ spec.implementation_files.each do |file|
81
+ @target.add_source_file(file, nil, spec.compiler_flags)
82
+ end
83
+ # Symlink header files to Pods/Headers
84
+ spec.copy_header_mappings.each do |header_dir, files|
85
+ target_dir = "#{headers_symlink_path_name}/#{header_dir}"
86
+ FileUtils.mkdir_p(target_dir)
87
+ target_dir_real_path = Pathname.new(target_dir).realpath
88
+ files.each do |file|
89
+ source = Pathname.new("#{config.project_pods_root}/#{file}").realpath.relative_path_from(target_dir_real_path)
90
+ Dir.chdir(target_dir) do
91
+ FileUtils.ln_sf(source, File.basename(file))
92
+ end
93
+ end
94
+ end
95
+ # Collect all header search paths
96
+ header_search_paths.concat(spec.header_search_paths)
97
+ end
98
+ xcconfig.merge!('HEADER_SEARCH_PATHS' => header_search_paths.sort.uniq.join(" "))
99
+
100
+ # Now that we have added all the source files and copy header phases,
101
+ # move the compile build phase to the end, so that headers are copied
102
+ # to the build products dir first, and thus Pod source files can enjoy
103
+ # the same namespacing of headers as the app would.
104
+ @target.move_compile_phase_to_end!
105
+
106
+ # Add all the target related support files to the group, even the copy
107
+ # resources script although the project doesn't actually use them.
108
+ support_files_group = @project.groups.find do |group|
109
+ group.name == "Targets Support Files"
110
+ end.groups.new("name" => @definition.lib_name)
111
+ support_files_group.files.new('path' => copy_resources_filename)
112
+ prefix_file = support_files_group.files.new('path' => prefix_header_filename)
113
+ xcconfig_file = support_files_group.files.new("path" => xcconfig_filename)
114
+ # Assign the xcconfig as the base config of each config.
115
+ @target.buildConfigurations.each do |config|
116
+ config.baseConfiguration = xcconfig_file
117
+ config.buildSettings['OTHER_LDFLAGS'] = ''
118
+ config.buildSettings['GCC_PREFIX_HEADER'] = prefix_header_filename
119
+ config.buildSettings['PODS_ROOT'] = '$(SRCROOT)'
120
+ end
121
+ end
122
+
123
+ def create_files_in(root)
124
+ if @podfile.generate_bridge_support?
125
+ puts "* Generating BridgeSupport metadata file at `#{root + bridge_support_filename}'" if config.verbose?
126
+ bridge_support_generator.save_as(root + bridge_support_filename)
127
+ copy_resources_script.resources << bridge_support_filename
128
+ end
129
+ puts "* Generating xcconfig file at `#{root + xcconfig_filename}'" if config.verbose?
130
+ xcconfig.save_as(root + xcconfig_filename)
131
+ puts "* Generating prefix header at `#{root + prefix_header_filename}'" if config.verbose?
132
+ save_prefix_header_as(root + prefix_header_filename)
133
+ puts "* Generating copy resources script at `#{root + copy_resources_filename}'" if config.verbose?
134
+ copy_resources_script.save_as(root + copy_resources_filename)
135
+ end
136
+ end
137
+ end
138
+ end
139
+
@@ -7,7 +7,7 @@ module Pod
7
7
  def resolve
8
8
  @sets, @loaded_spec_names, @specs = [], [], []
9
9
  find_dependency_sets(@specification, @dependencies)
10
- @specs
10
+ @specs.sort_by(&:name)
11
11
  end
12
12
 
13
13
  def find_dependency_sets(specification, dependencies = nil)
@@ -331,55 +331,6 @@ module Pod
331
331
  end
332
332
  end
333
333
 
334
- # Install and download hooks
335
-
336
- # Override this if you need to perform work before or after activating the
337
- # pod. Eg:
338
- #
339
- # Pod::Spec.new do |s|
340
- # def s.install!
341
- # # pre-install
342
- # super
343
- # # post-install
344
- # end
345
- # end
346
- #
347
- # TODO Do we really need this now that we don’t install the podspec files anymore?
348
- def install!
349
- puts "==> Installing: #{self}" unless config.silent?
350
- # In case this spec is part of another pod's source, we need to dowload
351
- # the other pod's source.
352
- (part_of_specification || self).download_if_necessary!
353
- end
354
-
355
- def download_if_necessary!
356
- if pod_destroot.exist?
357
- puts " * Skipping download of #{self}, pod already downloaded" unless config.silent?
358
- else
359
- puts " * Downloading: #{self}" unless config.silent?
360
- download!
361
- end
362
- end
363
-
364
- # Downloads the source of the pod and places it in the project's pods
365
- # directory.
366
- #
367
- # Override this if you need to perform work before or after downloading the
368
- # pod, or if you need to implement custom dowloading. Eg:
369
- #
370
- # Pod::Spec.new do |s|
371
- # def s.download!
372
- # # pre-download
373
- # super # or custom downloading
374
- # # post-download
375
- # end
376
- # end
377
- def download!
378
- downloader = Downloader.for_source(pod_destroot, source)
379
- downloader.download
380
- downloader.clean(expanded_clean_paths) if config.clean
381
- end
382
-
383
334
  # This is a convenience method which gets called after all pods have been
384
335
  # downloaded, installed, and the Xcode project and related files have been
385
336
  # generated. (It receives the Pod::Installer::Target instance for the current
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 8
9
- version: 0.3.8
8
+ - 9
9
+ version: 0.3.9
10
10
  platform: ruby
11
11
  authors:
12
12
  - Eloy Duran
@@ -61,6 +61,7 @@ files:
61
61
  - lib/cocoapods/file_list.rb
62
62
  - lib/cocoapods/generator/bridge_support.rb
63
63
  - lib/cocoapods/generator/copy_resources_script.rb
64
+ - lib/cocoapods/installer/target_installer.rb
64
65
  - lib/cocoapods/installer.rb
65
66
  - lib/cocoapods/podfile.rb
66
67
  - lib/cocoapods/resolver.rb