cocoapods 0.20.2 → 0.21.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -51,10 +51,11 @@ module Pod
51
51
  @result.podfile_state = generate_podfile_state
52
52
  @locked_dependencies = generate_version_locking_dependencies
53
53
 
54
- @result.libraries = generated_libraries
54
+ compute_target_platforms
55
55
  fetch_external_sources if allow_fetches
56
56
  @result.specs_by_target = resolve_dependencies
57
57
  @result.specifications = generate_specifications
58
+ @result.targets = generate_targets
58
59
  @result.sandbox_state = generate_sandbox_state
59
60
  @result
60
61
  end
@@ -158,44 +159,40 @@ module Pod
158
159
 
159
160
  # Creates the models that represent the libraries generated by CocoaPods.
160
161
  #
161
- # @note The libraries are generated before the resolution process
162
- # because it might be necessary to infer the platform from the
163
- # user targets, which in turns requires to identify the user
164
- # project.
165
- #
166
- # @note The specification of the libraries are added in the
167
- # {#resolve_dependencies} step.
168
- #
169
162
  # @return [Array<Libraries>] the generated libraries.
170
163
  #
171
- def generated_libraries
172
- libraries = []
173
- podfile.target_definition_list.each do |target_definition|
174
- lib = Library.new(target_definition)
175
- lib.support_files_root = sandbox.library_support_files_dir(lib.name)
164
+ def generate_targets
165
+ targets = []
166
+ result.specs_by_target.each do |target_definition, specs|
167
+ target = AggregateTarget.new(target_definition, sandbox)
168
+ targets << target
176
169
 
177
170
  if config.integrate_targets?
178
171
  project_path = compute_user_project_path(target_definition)
179
172
  user_project = Xcodeproj::Project.new(project_path)
180
- targets = compute_user_project_targets(target_definition, user_project)
173
+ native_targets = compute_user_project_targets(target_definition, user_project)
181
174
 
182
- lib.user_project_path = project_path
183
- lib.client_root = project_path.dirname
184
- lib.user_target_uuids = targets.map(&:uuid)
185
- lib.user_build_configurations = compute_user_build_configurations(target_definition, targets)
186
- lib.platform = compute_platform_for_target_definition(target_definition, targets)
175
+ target.user_project_path = project_path
176
+ target.client_root = project_path.dirname
177
+ target.user_target_uuids = native_targets.map(&:uuid)
178
+ target.user_build_configurations = compute_user_build_configurations(target_definition, native_targets)
187
179
  else
188
- unless target_definition.platform
189
- raise Informative, "It is necessary to specify the platform in the Podfile if not integrating."
190
- end
191
- lib.client_root = config.installation_root
192
- lib.user_target_uuids = []
193
- lib.user_build_configurations = {}
194
- lib.platform = target_definition.platform
180
+ target.client_root = config.installation_root
181
+ target.user_target_uuids = []
182
+ target.user_build_configurations = {}
183
+ end
184
+
185
+ grouped_specs = specs.map do |spec|
186
+ specs.select { |s| s.root == spec.root }
187
+ end.uniq
188
+
189
+ grouped_specs.each do |pod_specs|
190
+ pod_target = PodTarget.new(pod_specs, target_definition, sandbox)
191
+ pod_target.user_build_configurations = target.user_build_configurations
192
+ target.pod_targets << pod_target
195
193
  end
196
- libraries << lib
197
194
  end
198
- libraries
195
+ targets
199
196
  end
200
197
 
201
198
  # Generates dependencies that require the specific version of the Pods
@@ -263,8 +260,6 @@ module Pod
263
260
 
264
261
  # Converts the Podfile in a list of specifications grouped by target.
265
262
  #
266
- # @note In this step the specs are added to the libraries.
267
- #
268
263
  # @note As some dependencies might have external sources the resolver
269
264
  # is aware of the {Sandbox} and interacts with it to download the
270
265
  # podspecs of the external sources. This is necessary because the
@@ -284,17 +279,10 @@ module Pod
284
279
  #
285
280
  def resolve_dependencies
286
281
  specs_by_target = nil
287
-
288
282
  UI.section "Resolving dependencies of #{UI.path podfile.defined_in_file}" do
289
283
  resolver = Resolver.new(sandbox, podfile, locked_dependencies)
290
284
  specs_by_target = resolver.resolve
291
285
  end
292
-
293
- specs_by_target.each do |target_definition, specs|
294
- lib = result.libraries.find { |l| l.target_definition == target_definition}
295
- lib.specs = specs
296
- end
297
-
298
286
  specs_by_target
299
287
  end
300
288
 
@@ -449,6 +437,29 @@ module Pod
449
437
  Platform.new(name, deployment_target)
450
438
  end
451
439
 
440
+ # Precompute the platforms for each target_definition in the Podfile
441
+ #
442
+ # @note The platforms are computed and added to each target_definition
443
+ # because it might be necessary to infer the platform from the
444
+ # user targets.
445
+ #
446
+ # @return [void]
447
+ #
448
+ def compute_target_platforms
449
+ podfile.target_definition_list.each do |target_definition|
450
+ if config.integrate_targets?
451
+ project_path = compute_user_project_path(target_definition)
452
+ user_project = Xcodeproj::Project.new(project_path)
453
+ targets = compute_user_project_targets(target_definition, user_project)
454
+ platform = compute_platform_for_target_definition(target_definition, targets)
455
+ else
456
+ unless target_definition.platform
457
+ raise Informative, "It is necessary to specify the platform in the Podfile if not integrating."
458
+ end
459
+ end
460
+ end
461
+ end
462
+
452
463
  #-----------------------------------------------------------------------#
453
464
 
454
465
  class AnalysisResult
@@ -472,10 +483,10 @@ module Pod
472
483
  #
473
484
  attr_accessor :sandbox_state
474
485
 
475
- # @return [Array<Library>] the libraries generated by the target
476
- # definitions.
486
+ # @return [Array<Target>] The Podfile targets containing library
487
+ # dependencies.
477
488
  #
478
- attr_accessor :libraries
489
+ attr_accessor :targets
479
490
 
480
491
  end
481
492
 
@@ -107,18 +107,19 @@ module Pod
107
107
  #
108
108
  def link_headers
109
109
  UI.message "- Linking headers" do
110
-
111
- file_accessors.each do |file_accessor|
112
- headers_sandbox = Pathname.new(file_accessor.spec.root.name)
113
- sandbox.build_headers.add_search_path(headers_sandbox)
114
- sandbox.public_headers.add_search_path(headers_sandbox)
115
-
116
- header_mappings(headers_sandbox, file_accessor, file_accessor.headers).each do |namespaced_path, files|
117
- sandbox.build_headers.add_files(namespaced_path, files)
118
- end
119
-
120
- header_mappings(headers_sandbox, file_accessor, file_accessor.public_headers).each do |namespaced_path, files|
121
- sandbox.public_headers.add_files(namespaced_path, files)
110
+ libraries.each do |library|
111
+ library.file_accessors.each do |file_accessor|
112
+ headers_sandbox = Pathname.new(file_accessor.spec.root.name)
113
+ library.build_headers.add_search_path(headers_sandbox)
114
+ sandbox.public_headers.add_search_path(headers_sandbox)
115
+
116
+ header_mappings(headers_sandbox, file_accessor, file_accessor.headers).each do |namespaced_path, files|
117
+ library.build_headers.add_files(namespaced_path, files)
118
+ end
119
+
120
+ header_mappings(headers_sandbox, file_accessor, file_accessor.public_headers).each do |namespaced_path, files|
121
+ sandbox.public_headers.add_files(namespaced_path, files)
122
+ end
122
123
  end
123
124
  end
124
125
  end
@@ -24,30 +24,10 @@ module Pod
24
24
  @library = library
25
25
  end
26
26
 
27
- # Creates the target in the Pods project and the relative support files.
28
- #
29
- # @return [void]
30
- #
31
- def install!
32
- UI.message "- Installing target `#{library.name}` #{library.platform}" do
33
- add_target
34
- add_files_to_build_phases
35
- create_suport_files_group
36
-
37
- create_xcconfig_file
38
- create_target_environment_header
39
- create_prefix_header
40
- create_bridge_support_file
41
- create_copy_resources_script
42
- create_acknowledgements
43
- create_dummy_source
44
- end
45
- end
27
+ private
46
28
 
47
29
  #-----------------------------------------------------------------------#
48
30
 
49
- private
50
-
51
31
  # @!group Installation steps
52
32
 
53
33
  # Adds the target for the library to the Pods project with the
@@ -55,11 +35,6 @@ module Pod
55
35
  #
56
36
  # @note The `PODS_HEADERS_SEARCH_PATHS` overrides the xcconfig.
57
37
  #
58
- # @todo CocoaPods 0.16 used to add the build configurations to the build
59
- # configuration list of the project (`root object`) as well with
60
- # an empty build settings. This behaviour was changed in 0.17.
61
- # Restore if needed.
62
- #
63
38
  # @return [void]
64
39
  #
65
40
  def add_target
@@ -89,154 +64,13 @@ module Pod
89
64
  library.target = @target
90
65
  end
91
66
 
92
- # Adds the build files of the pods to the target and adds a reference to
93
- # the frameworks of the Pods.
94
- #
95
- # @note The Frameworks are used only for presentation purposes as the
96
- # xcconfig is the authoritative source about their information.
97
- #
98
- # @return [void]
99
- #
100
- def add_files_to_build_phases
101
- UI.message "- Adding Build files" do
102
- library.file_accessors.each do |file_accessor|
103
- consumer = file_accessor.spec_consumer
104
- flags = compiler_flags_for_consumer(consumer)
105
- source_files = file_accessor.source_files
106
- file_refs = source_files.map { |sf| project.file_reference(sf) }
107
- target.add_file_references(file_refs, flags)
108
-
109
- file_accessor.spec_consumer.frameworks.each do |framework|
110
- project.add_system_framework(framework, target)
111
- end
112
- end
113
- end
114
- end
115
-
116
67
  # Creates the group that holds the references to the support files
117
68
  # generated by this installer.
118
69
  #
119
70
  # @return [void]
120
71
  #
121
72
  def create_suport_files_group
122
- name = target_definition.label
123
- @support_files_group = project.support_files_group.new_group(name)
124
- end
125
-
126
- #--------------------------------------#
127
-
128
- # Generates the contents of the xcconfig file and saves it to disk.
129
- #
130
- # @note The `ALWAYS_SEARCH_USER_PATHS` flag is enabled to support
131
- # libraries like `EmbedReader`.
132
- #
133
- # @return [void]
134
- #
135
- def create_xcconfig_file
136
- path = library.xcconfig_path
137
- UI.message "- Generating xcconfig file at #{UI.path(path)}" do
138
- gen = Generator::XCConfig.new(sandbox, spec_consumers, library.relative_pods_root)
139
- gen.set_arc_compatibility_flag = target_definition.podfile.set_arc_compatibility_flag?
140
- gen.save_as(path)
141
- library.xcconfig = gen.xcconfig
142
- xcconfig_file_ref = add_file_to_support_group(path)
143
-
144
- target.build_configurations.each do |c|
145
- c.base_configuration_reference = xcconfig_file_ref
146
- Generator::XCConfig.pods_project_settings.each do |key, value|
147
- c.build_settings[key] = value
148
- end
149
- end
150
- end
151
- end
152
-
153
- # Generates a header which allows to inspect at compile time the installed
154
- # pods and the installed specifications of a pod.
155
- #
156
- def create_target_environment_header
157
- path = library.target_environment_header_path
158
- UI.message "- Generating target environment header at #{UI.path(path)}" do
159
- generator = Generator::TargetEnvironmentHeader.new(library.specs)
160
- generator.save_as(path)
161
- add_file_to_support_group(path)
162
- end
163
- end
164
-
165
- # Creates a prefix header file which imports `UIKit` or `Cocoa` according
166
- # to the platform of the target. This file also include any prefix header
167
- # content reported by the specification of the pods.
168
- #
169
- # @return [void]
170
- #
171
- def create_prefix_header
172
- path = library.prefix_header_path
173
- UI.message "- Generating prefix header at #{UI.path(path)}" do
174
- generator = Generator::PrefixHeader.new(library.file_accessors, library.platform)
175
- generator.imports << library.target_environment_header_path.basename
176
- generator.save_as(path)
177
- add_file_to_support_group(path)
178
-
179
- target.build_configurations.each do |c|
180
- relative_path = path.relative_path_from(sandbox.root)
181
- c.build_settings['GCC_PREFIX_HEADER'] = relative_path.to_s
182
- end
183
- end
184
- end
185
-
186
- # Generates the bridge support metadata if requested by the {Podfile}.
187
- #
188
- # @note The bridge support metadata is added to the resources of the
189
- # library because it is needed for environments interpreted at
190
- # runtime.
191
- #
192
- # @return [void]
193
- #
194
- def create_bridge_support_file
195
- if target_definition.podfile.generate_bridge_support?
196
- path = library.bridge_support_path
197
- UI.message "- Generating BridgeSupport metadata at #{UI.path(path)}" do
198
- headers = target.headers_build_phase.files.map { |bf| sandbox.root + bf.file_ref.path }
199
- generator = Generator::BridgeSupport.new(headers)
200
- generator.save_as(path)
201
- add_file_to_support_group(path)
202
- @bridge_support_file = path.relative_path_from(sandbox.root)
203
- end
204
- end
205
- end
206
-
207
- # Creates a script that copies the resources to the bundle of the client
208
- # target.
209
- #
210
- # @note The bridge support file needs to be created before the prefix
211
- # header, otherwise it will not be added to the resources script.
212
- #
213
- # @return [void]
214
- #
215
- def create_copy_resources_script
216
- path = library.copy_resources_script_path
217
- UI.message "- Generating copy resources script at #{UI.path(path)}" do
218
- resources = library.file_accessors.map { |accessor| accessor.resources.flatten.map {|res| project.relativize(res)} }.flatten
219
- resources << bridge_support_file if bridge_support_file
220
- generator = Generator::CopyResourcesScript.new(resources, library.platform)
221
- generator.save_as(path)
222
- add_file_to_support_group(path)
223
- end
224
- end
225
-
226
- # Generates the acknowledgement files (markdown and plist) for the target.
227
- #
228
- # @return [void]
229
- #
230
- def create_acknowledgements
231
- basepath = library.acknowledgements_basepath
232
- Generator::Acknowledgements.generators.each do |generator_class|
233
- path = generator_class.path_from_basepath(basepath)
234
- UI.message "- Generating acknowledgements at #{UI.path(path)}" do
235
- generator = generator_class.new(library.file_accessors)
236
- generator.save_as(path)
237
- add_file_to_support_group(path)
238
- end
239
- end
73
+ @support_files_group = project.support_files_group.new_group(library.name)
240
74
  end
241
75
 
242
76
  # Generates a dummy source file for each target so libraries that contain
@@ -254,10 +88,6 @@ module Pod
254
88
  end
255
89
  end
256
90
 
257
- #-----------------------------------------------------------------------#
258
-
259
- private
260
-
261
91
  # @return [PBXNativeTarget] the target generated by the installation
262
92
  # process.
263
93
  #
@@ -265,6 +95,10 @@ module Pod
265
95
  #
266
96
  attr_reader :target
267
97
 
98
+ private
99
+
100
+ #-----------------------------------------------------------------------#
101
+
268
102
  # @!group Private helpers.
269
103
 
270
104
  # @return [Project] the Pods project of the sandbox.
@@ -279,24 +113,11 @@ module Pod
279
113
  library.target_definition
280
114
  end
281
115
 
282
- # @return [Specification::Consumer] the consumer for the specifications.
283
- #
284
- def spec_consumers
285
- @spec_consumers ||= library.file_accessors.map(&:spec_consumer)
286
- end
287
-
288
116
  # @return [PBXGroup] the group where the file references to the support
289
117
  # files should be stored.
290
118
  #
291
119
  attr_reader :support_files_group
292
120
 
293
- # @return [Pathname] the path of the bridge support file relative to the
294
- # sandbox.
295
- #
296
- # @return [Nil] if no bridge support file was generated.
297
- #
298
- attr_reader :bridge_support_file
299
-
300
121
  # Adds a reference to the given file in the support group of this target.
301
122
  #
302
123
  # @param [Pathname] path
@@ -309,62 +130,6 @@ module Pod
309
130
  support_files_group.new_file(relative_path)
310
131
  end
311
132
 
312
- ENABLE_OBJECT_USE_OBJC_FROM = {
313
- :ios => Version.new('6'),
314
- :osx => Version.new('10.8')
315
- }
316
-
317
- # Returns the compiler flags for the source files of the given specification.
318
- #
319
- # The following behavior is regarding the `OS_OBJECT_USE_OBJC` flag. When
320
- # set to `0`, it will allow code to use `dispatch_release()` on >= iOS 6.0
321
- # and OS X 10.8.
322
- #
323
- # * New libraries that do *not* require ARC don’t need to care about this
324
- # issue at all.
325
- #
326
- # * New libraries that *do* require ARC _and_ have a deployment target of
327
- # >= iOS 6.0 or OS X 10.8:
328
- #
329
- # These no longer use `dispatch_release()` and should *not* have the
330
- # `OS_OBJECT_USE_OBJC` flag set to `0`.
331
- #
332
- # **Note:** this means that these libraries *have* to specify the
333
- # deployment target in order to function well.
334
- #
335
- # * New libraries that *do* require ARC, but have a deployment target of
336
- # < iOS 6.0 or OS X 10.8:
337
- #
338
- # These contain `dispatch_release()` calls and as such need the
339
- # `OS_OBJECT_USE_OBJC` flag set to `1`.
340
- #
341
- # **Note:** libraries that do *not* specify a platform version are
342
- # assumed to have a deployment target of < iOS 6.0 or OS X 10.8.
343
- #
344
- # For more information, see: http://opensource.apple.com/source/libdispatch/libdispatch-228.18/os/object.h
345
- #
346
- # @param [Specification::Consumer] consumer
347
- # The consumer for the specification for which the compiler flags
348
- # are needed.
349
- #
350
- # @return [String] The compiler flags.
351
- #
352
- def compiler_flags_for_consumer(consumer)
353
- flags = consumer.compiler_flags.dup
354
- if consumer.requires_arc
355
- flags << '-fobjc-arc'
356
- platform_name = consumer.platform_name
357
- spec_deployment_target = consumer.spec.deployment_target(platform_name)
358
- if spec_deployment_target.nil? || Version.new(spec_deployment_target) < ENABLE_OBJECT_USE_OBJC_FROM[platform_name]
359
- flags << '-DOS_OBJECT_USE_OBJC=0'
360
- end
361
- end
362
- if target_definition.inhibits_warnings_for_pod?(consumer.spec.root.name)
363
- flags << '-w -Xanalyzer -analyzer-disable-checker'
364
- end
365
- flags * " "
366
- end
367
-
368
133
  #-----------------------------------------------------------------------#
369
134
 
370
135
  end