cocoapods-core 0.30.0 → 1.15.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +7 -10
  3. data/lib/cocoapods-core/build_type.rb +121 -0
  4. data/lib/cocoapods-core/cdn_source.rb +501 -0
  5. data/lib/cocoapods-core/core_ui.rb +4 -3
  6. data/lib/cocoapods-core/dependency.rb +100 -73
  7. data/lib/cocoapods-core/gem_version.rb +1 -2
  8. data/lib/cocoapods-core/github.rb +32 -5
  9. data/lib/cocoapods-core/http.rb +86 -0
  10. data/lib/cocoapods-core/lockfile.rb +161 -56
  11. data/lib/cocoapods-core/metrics.rb +47 -0
  12. data/lib/cocoapods-core/platform.rb +99 -11
  13. data/lib/cocoapods-core/podfile/dsl.rb +623 -124
  14. data/lib/cocoapods-core/podfile/target_definition.rb +662 -109
  15. data/lib/cocoapods-core/podfile.rb +138 -65
  16. data/lib/cocoapods-core/requirement.rb +37 -8
  17. data/lib/cocoapods-core/source/acceptor.rb +16 -13
  18. data/lib/cocoapods-core/source/aggregate.rb +79 -103
  19. data/lib/cocoapods-core/source/health_reporter.rb +9 -18
  20. data/lib/cocoapods-core/source/manager.rb +488 -0
  21. data/lib/cocoapods-core/source/metadata.rb +79 -0
  22. data/lib/cocoapods-core/source.rb +241 -70
  23. data/lib/cocoapods-core/specification/consumer.rb +187 -47
  24. data/lib/cocoapods-core/specification/dsl/attribute.rb +49 -85
  25. data/lib/cocoapods-core/specification/dsl/attribute_support.rb +6 -8
  26. data/lib/cocoapods-core/specification/dsl/deprecations.rb +9 -126
  27. data/lib/cocoapods-core/specification/dsl/platform_proxy.rb +30 -20
  28. data/lib/cocoapods-core/specification/dsl.rb +943 -296
  29. data/lib/cocoapods-core/specification/json.rb +64 -23
  30. data/lib/cocoapods-core/specification/linter/analyzer.rb +218 -0
  31. data/lib/cocoapods-core/specification/linter/result.rb +128 -0
  32. data/lib/cocoapods-core/specification/linter.rb +310 -309
  33. data/lib/cocoapods-core/specification/root_attribute_accessors.rb +90 -39
  34. data/lib/cocoapods-core/specification/set/presenter.rb +35 -71
  35. data/lib/cocoapods-core/specification/set.rb +42 -96
  36. data/lib/cocoapods-core/specification.rb +368 -130
  37. data/lib/cocoapods-core/standard_error.rb +45 -24
  38. data/lib/cocoapods-core/trunk_source.rb +14 -0
  39. data/lib/cocoapods-core/vendor/requirement.rb +133 -53
  40. data/lib/cocoapods-core/vendor/version.rb +197 -156
  41. data/lib/cocoapods-core/vendor.rb +1 -5
  42. data/lib/cocoapods-core/version.rb +137 -42
  43. data/lib/cocoapods-core/yaml_helper.rb +334 -0
  44. data/lib/cocoapods-core.rb +10 -4
  45. metadata +100 -27
  46. data/lib/cocoapods-core/source/abstract_data_provider.rb +0 -71
  47. data/lib/cocoapods-core/source/file_system_data_provider.rb +0 -150
  48. data/lib/cocoapods-core/source/github_data_provider.rb +0 -143
  49. data/lib/cocoapods-core/specification/set/statistics.rb +0 -266
  50. data/lib/cocoapods-core/yaml_converter.rb +0 -192
@@ -1,46 +1,113 @@
1
1
  module Pod
2
2
  class Podfile
3
-
4
- # The of the methods defined in this file and the order of the methods is
3
+ # The methods defined in this file and the order of the methods is
5
4
  # relevant for the documentation generated on
6
- # CocoaPods/cocoapods.github.com.
5
+ # https://github.com/CocoaPods/guides.cocoapods.org.
7
6
 
8
7
  # The Podfile is a specification that describes the dependencies of the
9
- # targets of one or more Xcode projects. The Podfile always creates an
10
- # implicit target, named `default`, which links to the first target of the
11
- # user project.
8
+ # targets of one or more Xcode projects.
12
9
  #
13
- # A podfile can be very simple:
10
+ # A Podfile can be very simple:
14
11
  #
12
+ # target 'MyApp'
15
13
  # pod 'AFNetworking', '~> 1.0'
16
14
  #
17
- # An example of a more complex podfile can be:
15
+ # An example of a more complex Podfile can be:
18
16
  #
19
- # platform :ios, '6.0'
17
+ # platform :ios, '9.0'
20
18
  # inhibit_all_warnings!
21
19
  #
22
- # xcodeproj 'MyProject'
23
- #
24
- # pod 'ObjectiveSugar', '~> 0.5'
20
+ # target 'MyApp' do
21
+ # pod 'ObjectiveSugar', '~> 0.5'
25
22
  #
26
- # target :test do
27
- # pod 'OCMock', '~> 2.0.1'
23
+ # target 'MyAppTests' do
24
+ # inherit! :search_paths
25
+ # pod 'OCMock', '~> 2.0.1'
26
+ # end
28
27
  # end
29
28
  #
30
29
  # post_install do |installer|
31
- # installer.project.targets.each do |target|
30
+ # installer.pods_project.targets.each do |target|
32
31
  # puts "#{target.name}"
33
32
  # end
34
33
  # end
35
34
  #
36
35
  module DSL
36
+ # @!group Root Options
37
+ # Configuration that applies to the Podfile as a whole.
38
+ #
39
+ # * `install!` declares the installation method and options to be used
40
+ # during installation.
41
+
42
+ # Specifies the installation method and options to be used when
43
+ # CocoaPods installs this Podfile.
44
+ #
45
+ # The first parameter indicates the installation method to use;
46
+ # next parameters indicate installation options.
47
+ #
48
+ # For now the only accepted installation method is `'cocoapods'`, so
49
+ # you'll always use this value for the first parameter; but more
50
+ # installation methods might be available in future versions.
51
+ #
52
+ # @param [String] installation_method
53
+ # the name of the installation strategy.
54
+ #
55
+ # @param [Hash] options
56
+ # the installation options.
57
+ #
58
+ # @example Specifying custom CocoaPods installation options
59
+ #
60
+ # install! 'cocoapods',
61
+ # :deterministic_uuids => false,
62
+ # :integrate_targets => false
63
+ #
64
+ # @return [void]
65
+ #
66
+ def install!(installation_method, options = {})
67
+ unless current_target_definition.root?
68
+ raise Informative, 'The installation method can only be set at the root level of the Podfile.'
69
+ end
70
+
71
+ set_hash_value('installation_method', 'name' => installation_method, 'options' => options)
72
+ end
73
+
74
+ # Raises a warning when CocoaPods is run using the Global Gemset.
75
+ # A Semantic version can be supplied to warn if the bundler version
76
+ # does not match the required version.
77
+ #
78
+ # @param [String] version
79
+ # The required bundler version, in semantic version format.
80
+ #
81
+ # @example
82
+ #
83
+ # ensure_bundler!
84
+ #
85
+ # @example
86
+ #
87
+ # ensure_bundler! '~> 2.0.0'
88
+ #
89
+ # @return [void]
90
+ #
91
+ def ensure_bundler!(version = nil)
92
+ unless current_target_definition.root?
93
+ raise Informative, 'The Ensure Bundler check can only be set at the root level of the Podfile.'
94
+ end
95
+ unless %w(BUNDLE_BIN_PATH BUNDLE_GEMFILE).all? { |key| ENV.key?(key) }
96
+ raise Informative, "CocoaPods was invoked from Global Gemset.\nPlease re-run using: `bundle exec pod #{ARGV.join(' ')}`"
97
+ end
98
+ unless ENV['BUNDLER_VERSION'].nil? || Requirement.create(version).satisfied_by?(Version.new(ENV['BUNDLER_VERSION']))
99
+ raise Informative, "The installed Bundler version: #{ENV['BUNDLER_VERSION']} does not match the required version: #{version}"
100
+ end
101
+ end
102
+
103
+ #-----------------------------------------------------------------------#
37
104
 
38
105
  # @!group Dependencies
39
106
  # The Podfile specifies the dependencies of each user target.
40
107
  #
41
108
  # * `pod` is the way to declare a specific dependency.
42
- # * `podspec` provides an easy creation API for local podspecs.
43
- # * `target` allows you to scope your dependencies to specific
109
+ # * `podspec` provides an easy API for the creation of podspecs.
110
+ # * `target` is how you scope your dependencies to specific
44
111
  # targets in your Xcode projects.
45
112
 
46
113
  #-----------------------------------------------------------------------#
@@ -64,6 +131,7 @@ module Pod
64
131
  # Besides no version, or a specific one, it is also possible to use
65
132
  # operators:
66
133
  #
134
+ # * `= 0.1` Version 0.1.
67
135
  # * `> 0.1` Any version higher than 0.1.
68
136
  # * `>= 0.1` Version 0.1 and any higher version.
69
137
  # * `< 0.1` Any version lower than 0.1.
@@ -73,6 +141,10 @@ module Pod
73
141
  # specify in your version requirement. The example is equal to
74
142
  # `>= 0.1.2` combined with `< 0.2.0` and will always match the
75
143
  # latest known version matching your requirements.
144
+ # * `~> 0` Version 0 and the versions up to 1, not including 1.
145
+ # * `~> 0.1.3-beta.0` Beta and release versions for 0.1.3, release versions
146
+ # up to 0.2 excluding 0.2. Components separated by a dash (-)
147
+ # will not be considered for the version requirement.
76
148
  #
77
149
  # A list of version requirements can be specified for even more fine
78
150
  # grained control.
@@ -80,14 +152,80 @@ module Pod
80
152
  # For more information, regarding versioning policy, see:
81
153
  #
82
154
  # * [Semantic Versioning](http://semver.org)
83
- # * [RubyGems Versioning Policies](http://docs.rubygems.org/read/chapter/7)
155
+ # * [RubyGems Versioning Policies](http://guides.rubygems.org/patterns/#semantic-versioning)
156
+ #
157
+ # ------
158
+ #
159
+ # ### Build configurations
160
+ #
161
+ # By default dependencies are installed in all the build configurations
162
+ # of the target. For debug purposes or for other reasons, they can be
163
+ # only enabled on a list of build configurations.
164
+ #
165
+ # pod 'PonyDebugger', :configurations => ['Debug', 'Beta']
166
+ #
167
+ # Alternatively, you can specify to have it included on a single build
168
+ # configuration.
169
+ #
170
+ # pod 'PonyDebugger', :configuration => 'Debug'
171
+ #
172
+ # Note that transitive dependencies are included in all configurations
173
+ # and you have to manually specify build configurations for them as well in
174
+ # case this is not desired.
175
+ #
176
+ # ------
177
+ #
178
+ # ### Modular Headers
179
+ #
180
+ # If you would like to use modular headers per Pod you can use the
181
+ # following syntax:
182
+ #
183
+ # pod 'SSZipArchive', :modular_headers => true
184
+ #
185
+ # Additionally, when you use the `use_modular_headers!` attribute,
186
+ # you can exclude a particular Pod from modular headers using the following:
187
+ #
188
+ # pod 'SSZipArchive', :modular_headers => false
189
+ #
190
+ # ------
191
+ #
192
+ # ### Source
193
+ #
194
+ # By default the sources specified at the global level are searched in the order
195
+ # they are specified for a dependency match. This behaviour can be altered
196
+ # for a specific dependency by specifying the source with the dependency:
197
+ #
198
+ # pod 'PonyDebugger', :source => 'https://cdn.cocoapods.org/'
199
+ #
200
+ # In this case only the specified source will be searched for the dependency
201
+ # and any global sources ignored.
202
+ #
203
+ # ------
204
+ #
205
+ # ### Subspecs
206
+ #
207
+ # When installing a Pod via its name, it will install all of the
208
+ # default subspecs defined in the podspec.
209
+ #
210
+ # You may install a specific subspec using the following:
211
+ #
212
+ # pod 'QueryKit/Attribute'
213
+ #
214
+ # You may specify a collection of subspecs to be installed as follows:
215
+ #
216
+ # pod 'QueryKit', :subspecs => ['Attribute', 'QuerySet']
217
+ #
218
+ # ### Test Specs
219
+ #
220
+ # Test specs can be optionally included via the `:testspecs` option. By default,
221
+ # none of a Pod's test specs are included.
84
222
  #
85
- # Finally, instead of a version, you can specify the `:head` flag. This
86
- # will use the spec of the newest available version in your spec repo(s),
87
- # but force the download of the ‘bleeding edge’ version (HEAD). Use this
88
- # with caution, as the spec _might_ not be compatible anymore.
223
+ # You may specify a list of test spec names to install using the following:
89
224
  #
90
- # pod 'Objection', :head
225
+ # pod 'AFNetworking', :testspecs => ['UnitTests', 'SomeOtherTests']
226
+ #
227
+ # The values provided to `:testspecs` correspond to the name provided to the
228
+ # `test_spec` DSL attribute in a Podspec.
91
229
  #
92
230
  # ------
93
231
  #
@@ -96,7 +234,7 @@ module Pod
96
234
  #
97
235
  # ### Using the files from a local path.
98
236
  #
99
- # If you wold like to use develop a Pod in tandem with its client
237
+ # If you would like to use develop a Pod in tandem with its client
100
238
  # project you can use the `path` option.
101
239
  #
102
240
  # pod 'AFNetworking', :path => '~/Documents/AFNetworking'
@@ -106,24 +244,34 @@ module Pod
106
244
  # Pods project. This means that your edits will persist to CocoaPods
107
245
  # installations.
108
246
  #
109
- # The referenced folder can be a checkout of your your favorite SCM or
110
- # even a git submodule of the current repo.
247
+ # The referenced folder can be a checkout of your your favourite SCM or
248
+ # even a git submodule of the current repository.
111
249
  #
112
250
  # Note that the `podspec` of the Pod file is expected to be in the
113
251
  # folder.
114
252
  #
115
253
  #
116
- # ### From a podspec in the root of a library repo.
254
+ # ### From a podspec in the root of a library repository.
117
255
  #
118
256
  # Sometimes you may want to use the bleeding edge version of a Pod. Or a
119
257
  # specific revision. If this is the case, you can specify that with your
120
258
  # pod declaration.
121
259
  #
122
- # To use the `master` branch of the repo:
260
+ # To use the `master` branch of the repository:
123
261
  #
124
262
  # pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git'
125
263
  #
126
264
  #
265
+ # To use a different branch of the repository:
266
+ #
267
+ # pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :branch => 'dev'
268
+ #
269
+ #
270
+ # To use a tag of the repository:
271
+ #
272
+ # pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :tag => '0.7.0'
273
+ #
274
+ #
127
275
  # Or specify a commit:
128
276
  #
129
277
  # pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :commit => '082f8319af'
@@ -131,42 +279,38 @@ module Pod
131
279
  # It is important to note, though, that this means that the version will
132
280
  # have to satisfy any other dependencies on the Pod by other Pods.
133
281
  #
134
- # The `podspec` file is expected to be in the root of the repo, if this
135
- # library does not have a `podspec` file in its repo yet, you will have
136
- # to use one of the approaches outlined in the sections below.
282
+ # The `podspec` file is expected to be in the root of the repository,
283
+ # if this library does not have a `podspec` file in its repository
284
+ # yet, you will have to use one of the approaches outlined in the
285
+ # sections below.
137
286
  #
138
287
  #
139
- # ### From a podspec outside a spec repo, for a library without podspec.
288
+ # ### From a podspec outside a spec repository, for a library without podspec.
140
289
  #
141
290
  # If a podspec is available from another source outside of the library’s
142
- # repo. Consider, for instance, a podspec available via HTTP:
291
+ # repository. Consider, for instance, a podspec available via HTTP:
143
292
  #
144
- # pod 'JSONKit', :podspec => 'https://raw.github.com/gist/1346394/1d26570f68ca27377a27430c65841a0880395d72/JSONKit.podspec'
293
+ # pod 'JSONKit', :podspec => 'https://example.com/JSONKit.podspec'
145
294
  #
146
295
  #
147
296
  # @note This method allow a nil name and the raises to be more
148
297
  # informative.
149
298
  #
150
- # @note Support for inline podspecs has been deprecated.
151
- #
152
299
  # @return [void]
153
300
  #
154
- def pod(name = nil, *requirements, &block)
155
- if block
156
- raise StandardError, "Inline specifications are deprecated. " \
157
- "Please store the specification in a `podspec` file."
158
- end
159
-
301
+ def pod(name = nil, *requirements)
160
302
  unless name
161
- raise StandardError, "A dependency requires a name."
303
+ raise StandardError, 'A dependency requires a name.'
162
304
  end
163
305
 
164
306
  current_target_definition.store_pod(name, *requirements)
165
307
  end
166
308
 
167
- # Use the dependencies of a Pod defined in the given podspec file. If no
168
- # arguments are passed the first podspec in the root of the Podfile is
169
- # used. It is intended to be used by the project of a library.
309
+ # Use just the dependencies of a Pod defined in the given podspec file.
310
+ # If no arguments are passed the first podspec in the root of the Podfile
311
+ # is used. It is intended to be used by the project of a library. Note:
312
+ # this does not include the sources derived from the podspec just the
313
+ # CocoaPods infrastructure.
170
314
  #
171
315
  # @example
172
316
  # podspec
@@ -179,7 +323,7 @@ module Pod
179
323
  #
180
324
  # @param [Hash {Symbol=>String}] options
181
325
  # the path where to load the {Specification}. If not provided
182
- # the first podspec in the directory of the podfile is used.
326
+ # the first podspec in the directory of the Podfile is used.
183
327
  #
184
328
  # @option options [String] :path
185
329
  # the path of the podspec file
@@ -187,7 +331,7 @@ module Pod
187
331
  # @option options [String] :name
188
332
  # the name of the podspec
189
333
  #
190
- # @note This method uses the dependencies declared by the for the
334
+ # @note This method uses the dependencies declared for the
191
335
  # platform of the target definition.
192
336
  #
193
337
  #
@@ -200,61 +344,222 @@ module Pod
200
344
  current_target_definition.store_podspec(options)
201
345
  end
202
346
 
203
- # Defines a new static library target and scopes dependencies defined
204
- # from the given block. The target will by default include the
205
- # dependencies defined outside of the block, unless the `:exclusive =>
206
- # true` option is
207
- # given.
208
- #
209
- # ---
210
- #
211
- # The Podfile creates a global target named `:default` which produces the
212
- # `libPods.a` file. This target is linked with the first target of user
213
- # project if not value is specified for the `link_with` attribute.
347
+ # Defines a CocoaPods target and scopes dependencies defined
348
+ # within the given block. A target should correspond to an Xcode target.
349
+ # By default the target includes the dependencies defined outside of
350
+ # the block, unless instructed not to `inherit!` them.
214
351
  #
215
352
  # @param [Symbol, String] name
216
- # the name of the target definition.
217
- #
218
- # @option options [Bool] :exclusive
219
- # whether the target should inherit the dependencies of its
220
- # parent. by default targets are inclusive.
353
+ # the name of the target.
221
354
  #
222
355
  # @example Defining a target
223
356
  #
224
- # target :ZipApp do
357
+ # target 'ZipApp' do
225
358
  # pod 'SSZipArchive'
226
359
  # end
227
360
  #
228
- # @example Defining an exclusive target
361
+ # @example Defining a test target accessing SSZipArchive pod from its parent
229
362
  #
230
- # target :ZipApp do
363
+ # target 'ZipApp' do
231
364
  # pod 'SSZipArchive'
232
- # target :test, :exclusive => true do
233
- # pod 'JSONKit'
365
+ #
366
+ # target 'ZipAppTests' do
367
+ # inherit! :search_paths
368
+ # pod 'Nimble'
369
+ # end
370
+ # end
371
+ #
372
+ # @example Defining a target applies Pods to multiple targets via its parent target
373
+ #
374
+ # target 'ShowsApp' do
375
+ # pod 'ShowsKit'
376
+ #
377
+ # # Has its own copy of ShowsKit + ShowTVAuth
378
+ # target 'ShowsTV' do
379
+ # pod 'ShowTVAuth'
380
+ # end
381
+ #
382
+ # # Has its own copy of Specta + Expecta
383
+ # # and has access to ShowsKit via the app
384
+ # # that the test target is bundled into
385
+ #
386
+ # target 'ShowsTests' do
387
+ # inherit! :search_paths
388
+ # pod 'Specta'
389
+ # pod 'Expecta'
234
390
  # end
235
391
  # end
236
392
  #
237
393
  # @return [void]
238
394
  #
239
- def target(name, options = {})
240
- if options && !options.keys.all? { |key| [:exclusive].include?(key) }
395
+ def target(name, options = nil)
396
+ if options
241
397
  raise Informative, "Unsupported options `#{options}` for " \
242
- "target `#{name}`"
398
+ "target `#{name}`."
243
399
  end
244
400
 
245
401
  parent = current_target_definition
246
402
  definition = TargetDefinition.new(name, parent)
247
- definition.exclusive = true if options[:exclusive]
248
403
  self.current_target_definition = definition
249
- yield
404
+ yield if block_given?
250
405
  ensure
251
406
  self.current_target_definition = parent
252
407
  end
253
408
 
409
+ # Adds a script phase to be integrated with this target. A script phase can be used to execute an arbitrary
410
+ # script that can use all Xcode environment variables during execution. A target may include multiple script
411
+ # phases which they will be added in the order they were declared. Deleting a script phase will effectively remove
412
+ # it from the target if it has been added previously.
413
+ #
414
+ # @example
415
+ # script_phase :name => 'HelloWorldScript', :script => 'echo "Hello World"'
416
+ #
417
+ # @example
418
+ # script_phase :name => 'HelloWorldScript', :script => 'puts "Hello World"', :shell_path => '/usr/bin/ruby'
419
+ #
420
+ # @param [Hash] options
421
+ # the options for this script phase.
422
+ #
423
+ # @option options [String] :name
424
+ # the name of the script phase. This option is required.
425
+ #
426
+ # @option options [String] :script
427
+ # the body of the script to execute. This option is required.
428
+ #
429
+ # @option options [String] :shell_path
430
+ # the shell path to use for this script phase, for example `/usr/bin/ruby` to use Ruby for this phase.
431
+ #
432
+ # @option options [Array<String>] :input_files
433
+ # the input paths to use for this script phase. This is used by Xcode to determine whether to re-execute
434
+ # this script phase if the input paths have changed or not.
435
+ #
436
+ # @option options [Array<String>] :output_files
437
+ # the output paths to use for this script phase. This is used by Xcode to avoid re-executing this script
438
+ # phase if none of the output paths have changed.
439
+ #
440
+ # @option options [Array<String>] :input_file_lists
441
+ # the input file lists to use for this script phase. This is used by Xcode to determine whether to
442
+ # re-execute this script phase if the input paths have changed or not.
443
+ #
444
+ # @option options [Array<String>] :output_file_lists
445
+ # the output file lists to use for this script phase. This is used by Xcode to avoid re-executing this
446
+ # script phase if none of the output paths have changed.
447
+ #
448
+ # @option options [Boolean] :show_env_vars_in_log
449
+ # whether this script phase should output the environment variables during execution.
450
+ #
451
+ # @option options [Symbol] :execution_position
452
+ # specifies the position of which this script phase should be executed. The currently supported values are:
453
+ # `:before_compile`, `:after_compile` and `:any` which is the default.
454
+ #
455
+ # @option options [String] :dependency_file
456
+ # specifies the dependency file to use for this script phase.
457
+ #
458
+ # @option options [String] :always_out_of_date
459
+ # specifies whether or not this run script will be forced to
460
+ # run even on incremental builds
461
+ #
462
+ # @return [void]
463
+ #
464
+ def script_phase(options)
465
+ raise Informative, 'Script phases can only be added within target definitions.' if current_target_definition.root?
466
+ raise Informative, 'Script phases cannot be added to abstract targets.' if current_target_definition.abstract?
467
+ current_target_definition.store_script_phase(options)
468
+ end
469
+
470
+ # Defines a new abstract target that can be used for convenient
471
+ # target dependency inheritance.
472
+ #
473
+ # @param [Symbol, String] name
474
+ # the name of the target.
475
+ #
476
+ # @example Defining an abstract target
477
+ #
478
+ # abstract_target 'Networking' do
479
+ # pod 'AlamoFire'
480
+ #
481
+ # target 'Networking App 1'
482
+ # target 'Networking App 2'
483
+ # end
484
+ #
485
+ # @example Defining an abstract_target wrapping Pods to multiple targets
486
+ #
487
+ # # Note: There are no targets called "Shows" in any of this workspace's Xcode projects
488
+ # abstract_target 'Shows' do
489
+ # pod 'ShowsKit'
490
+ #
491
+ # # The target ShowsiOS has its own copy of ShowsKit (inherited) + ShowWebAuth (added here)
492
+ # target 'ShowsiOS' do
493
+ # pod 'ShowWebAuth'
494
+ # end
495
+ #
496
+ # # The target ShowsTV has its own copy of ShowsKit (inherited) + ShowTVAuth (added here)
497
+ # target 'ShowsTV' do
498
+ # pod 'ShowTVAuth'
499
+ # end
500
+ #
501
+ # # Our tests target has its own copy of
502
+ # # our testing frameworks, and has access
503
+ # # to ShowsKit as well because it is
504
+ # # a child of the abstract target 'Shows'
505
+ #
506
+ # target 'ShowsTests' do
507
+ # inherit! :search_paths
508
+ # pod 'Specta'
509
+ # pod 'Expecta'
510
+ # end
511
+ # end
512
+ #
513
+ # @return [void]
514
+ #
515
+ def abstract_target(name)
516
+ target(name) do
517
+ abstract!
518
+ yield if block_given?
519
+ end
520
+ end
521
+
522
+ # Denotes that the current target is abstract, and thus will not directly
523
+ # link against an Xcode target.
524
+ #
525
+ # @return [void]
526
+ #
527
+ def abstract!(abstract = true)
528
+ current_target_definition.abstract = abstract
529
+ end
530
+
531
+ # Sets the inheritance mode for the current target.
532
+ #
533
+ # @param [Symbol] inheritance
534
+ # the inheritance mode to set.
535
+ #
536
+ # **Available Modes:**
537
+ # + `:complete` The target inherits all
538
+ # behaviour from the parent.
539
+ # + `:none` The target inherits none of
540
+ # the behaviour from the parent.
541
+ # + `:search_paths` The target inherits
542
+ # the search paths of the parent only.
543
+ #
544
+ #
545
+ # @example Inheriting only search paths
546
+ #
547
+ # target 'App' do
548
+ # target 'AppTests' do
549
+ # inherit! :search_paths
550
+ # end
551
+ # end
552
+ #
553
+ # @return [void]
554
+ #
555
+ def inherit!(inheritance)
556
+ current_target_definition.inheritance = inheritance
557
+ end
558
+
254
559
  #-----------------------------------------------------------------------#
255
560
 
256
561
  # @!group Target configuration
257
- # These settings are used to control the CocoaPods generated project.
562
+ # These settings are used to control the CocoaPods generated project.
258
563
  #
259
564
  # This starts out simply with stating what `platform` you are working
260
565
  # on. `xcodeproj` allows you to state specifically which project to
@@ -262,17 +567,18 @@ module Pod
262
567
 
263
568
  #-----------------------------------------------------------------------#
264
569
 
265
- # Specifies the platform for which a static library should be build.
570
+ # Specifies the platform for which a static library should be built.
266
571
  #
267
572
  # CocoaPods provides a default deployment target if one is not specified.
268
- # The current default values are `4.3` for iOS and `10.6` for OS X.
573
+ # The current default values are `4.3` for iOS, `10.6` for OS X, `9.0` for tvOS,
574
+ # `1.0` for visionOS and `2.0` for watchOS.
269
575
  #
270
576
  # If the deployment target requires it (iOS < `4.3`), `armv6`
271
577
  # architecture will be added to `ARCHS`.
272
578
  #
273
579
  # @param [Symbol] name
274
- # the name of platform, can be either `:osx` for OS X or `:ios`
275
- # for iOS.
580
+ # the name of platform, can be either `:osx` for OS X, `:ios`
581
+ # for iOS, `:tvos` for tvOS, `:visionos` for visionOS, or `:watchos` for watchOS.
276
582
  #
277
583
  # @param [String, Version] target
278
584
  # The optional deployment. If not provided a default value
@@ -280,7 +586,7 @@ module Pod
280
586
  #
281
587
  # @example Specifying the platform
282
588
  #
283
- # platform :ios, "4.0"
589
+ # platform :ios, '4.0'
284
590
  # platform :ios
285
591
  #
286
592
  # @return [void]
@@ -288,7 +594,7 @@ module Pod
288
594
  def platform(name, target = nil)
289
595
  # Support for deprecated options parameter
290
596
  target = target[:deployment_target] if target.is_a?(Hash)
291
- current_target_definition.set_platform(name, target)
597
+ current_target_definition.set_platform!(name, target)
292
598
  end
293
599
 
294
600
  # Specifies the Xcode project that contains the target that the Pods
@@ -296,13 +602,12 @@ module Pod
296
602
  #
297
603
  # -----
298
604
  #
299
- # If no explicit project is specified, it will use the Xcode project of
300
- # the parent target. If none of the target definitions specify an
301
- # explicit project and there is only **one** project in the same
302
- # directory as the Podfile then that project will be used.
605
+ # If none of the target definitions specify an explicit project
606
+ # and there is only **one** project in the same directory as the Podfile
607
+ # then that project will be used.
303
608
  #
304
609
  # It is possible also to specify whether the build settings of your
305
- # custom build configurations should be modeled after the release or
610
+ # custom build configurations should be modelled after the release or
306
611
  # the debug presets. To do so you need to specify a hash where the name
307
612
  # of each build configuration is associated to either `:release` or
308
613
  # `:debug`.
@@ -320,51 +625,53 @@ module Pod
320
625
  #
321
626
  # @example Specifying the user project
322
627
  #
323
- # # Look for target to link with in an Xcode project called
324
- # # `MyProject.xcodeproj`.
325
- # xcodeproj 'MyProject'
628
+ # # This Target can be found in a Xcode project called `FastGPS`
629
+ # target 'MyGPSApp' do
630
+ # project 'FastGPS'
631
+ # ...
632
+ # end
326
633
  #
327
- # target :test do
328
- # # This Pods library links with a target in another project.
329
- # xcodeproj 'TestProject'
634
+ # # Same Podfile, multiple Xcodeprojects
635
+ # target 'MyNotesApp' do
636
+ # project 'FastNotes'
637
+ # ...
330
638
  # end
331
639
  #
332
640
  # @example Using custom build configurations
333
641
  #
334
- # xcodeproj 'TestProject', 'Mac App Store' => :release, 'Test' => :debug
335
- #
642
+ # project 'TestProject', 'Mac App Store' => :release, 'Test' => :debug
336
643
  #
337
644
  # @return [void]
338
645
  #
339
- def xcodeproj(path, build_configurations = {})
646
+ def project(path, build_configurations = {})
340
647
  current_target_definition.user_project_path = path
341
648
  current_target_definition.build_configurations = build_configurations
342
649
  end
343
650
 
344
- # Specifies the target(s) in the user’s project that this Pods library
345
- # should be linked in.
346
- #
347
- # -----
348
- #
349
- # If no explicit target is specified, then the Pods target will be linked
350
- # with the first target in your project. So if you only have one target
351
- # you do not need to specify the target to link with.
651
+ # @!visibility private
352
652
  #
353
- # @param [String, Array<String>] targets
354
- # the target or the targets to link with.
653
+ # @deprecated #{xcodeproj} was renamed to #{project}.
355
654
  #
356
- # @example Link with a user project target
655
+ # `xcodeproj` is deprecated in [1.0](http://blog.cocoapods.org/CocoaPods-1.0/) and has been renamed to `project`.
656
+ # For pre-1.0 versions use `xcodeproj`.
357
657
  #
358
- # link_with 'MyApp'
359
- #
360
- # @example Link with multiple user project targets
658
+ def xcodeproj(*args)
659
+ CoreUI.warn '`xcodeproj` was renamed to `project`. Please update your Podfile accordingly.'
660
+ project(*args)
661
+ end
662
+
663
+ # @!visibility private
361
664
  #
362
- # link_with 'MyApp', 'MyOtherApp'
665
+ # @deprecated linking a single target with multiple Xcode targets is no
666
+ # longer supported. Use an {#abstract_target} and target
667
+ # inheritance instead.
363
668
  #
364
- # @return [void]
669
+ # `link_with` is deprecated in [1.0](http://blog.cocoapods.org/CocoaPods-1.0/) in
670
+ # favour of `abstract_target` and target inheritance instead.
365
671
  #
366
- def link_with(*targets)
367
- current_target_definition.link_with = targets.flatten
672
+ def link_with(*)
673
+ raise Informative, 'The specification of `link_with` in the Podfile ' \
674
+ 'is now unsupported, please use target blocks instead.'
368
675
  end
369
676
 
370
677
  # Inhibits **all** the warnings from the CocoaPods libraries.
@@ -378,10 +685,103 @@ module Pod
378
685
  #
379
686
  # pod 'SSZipArchive', :inhibit_warnings => true
380
687
  #
688
+ # Additionally, when you use `inhibit_all_warnings!` attribute,
689
+ # you can exclude a particular Pod from being inhibited using the following:
690
+ #
691
+ # pod 'SSZipArchive', :inhibit_warnings => false
692
+ #
381
693
  def inhibit_all_warnings!
382
694
  current_target_definition.inhibit_all_warnings = true
383
695
  end
384
696
 
697
+ # Use modular headers for all CocoaPods static libraries.
698
+ #
699
+ # ------
700
+ #
701
+ # This attribute is inherited by child target definitions.
702
+ #
703
+ # If you would like to use modular headers per Pod you can use the
704
+ # following syntax:
705
+ #
706
+ # pod 'SSZipArchive', :modular_headers => true
707
+ #
708
+ # Additionally, when you use the `use_modular_headers!` attribute,
709
+ # you can exclude a particular Pod from modular headers using the following:
710
+ #
711
+ # pod 'SSZipArchive', :modular_headers => false
712
+ #
713
+ def use_modular_headers!
714
+ current_target_definition.use_modular_headers_for_all_pods = true
715
+ end
716
+
717
+ # Use frameworks instead of static libraries for Pods. When using frameworks, you may also specify the `:linkage`
718
+ # style to use, either `:static` or `:dynamic`.
719
+ #
720
+ # ------
721
+ #
722
+ # This attribute is inherited by child target definitions.
723
+ #
724
+ # @param [Boolean, Hash] option
725
+ # The option to use for configuring packaging and linkage style.
726
+ #
727
+ # @example
728
+ #
729
+ # target 'MyApp' do
730
+ # use_frameworks!
731
+ # pod 'AFNetworking', '~> 1.0'
732
+ # end
733
+ #
734
+ # @example
735
+ #
736
+ # target 'MyApp' do
737
+ # use_frameworks! :linkage => :dynamic
738
+ # pod 'AFNetworking', '~> 1.0'
739
+ # end
740
+ #
741
+ # target 'ZipApp' do
742
+ # use_frameworks! :linkage => :static
743
+ # pod 'SSZipArchive'
744
+ # end
745
+ #
746
+ # @return [void]
747
+ #
748
+ def use_frameworks!(option = true)
749
+ current_target_definition.use_frameworks!(option)
750
+ end
751
+
752
+ # Specifies the Swift version requirements this target definition supports.
753
+ #
754
+ # **Note** These requirements are inherited from the parent, if specified and if none
755
+ # are specified at the root level then all versions are considered to be supported.
756
+ #
757
+ # @param [String, Version, Array<String>, Array<Version>] requirements
758
+ # The set of requirements this target supports.
759
+ #
760
+ # @example
761
+ #
762
+ # target 'MyApp' do
763
+ # supports_swift_versions '>= 3.0', '< 4.0'
764
+ # pod 'AFNetworking', '~> 1.0'
765
+ # end
766
+ #
767
+ # @example
768
+ #
769
+ # supports_swift_versions '>= 3.0', '< 4.0'
770
+ #
771
+ # target 'MyApp' do
772
+ # pod 'AFNetworking', '~> 1.0'
773
+ # end
774
+ #
775
+ # target 'ZipApp' do
776
+ # pod 'SSZipArchive'
777
+ # end
778
+ #
779
+ # @return [void]
780
+ #
781
+ def supports_swift_versions(*requirements)
782
+ current_target_definition.store_swift_version_requirements(*requirements)
783
+ end
784
+
385
785
  #-----------------------------------------------------------------------#
386
786
 
387
787
  # @!group Workspace
@@ -448,6 +848,44 @@ module Pod
448
848
 
449
849
  #-----------------------------------------------------------------------#
450
850
 
851
+ # @!group Sources
852
+ #
853
+ # The Podfile retrieves specs from a given list of sources (repositories).
854
+ #
855
+ # Sources are __global__ and they are not stored per target definition.
856
+
857
+ #-----------------------------------------------------------------------#
858
+
859
+ # Specifies the location of specs
860
+ #
861
+ # -----
862
+ #
863
+ # Use this method to specify sources. The order of the sources is
864
+ # relevant. CocoaPods will use the highest version of a Pod of the first
865
+ # source which includes the Pod (regardless whether other sources have a
866
+ # higher version).
867
+ #
868
+ # The official CocoaPods source is implicit.
869
+ # Once you specify another source, then it will need to be included.
870
+ #
871
+ # @param [String] source
872
+ # The URL of a specs repository.
873
+ #
874
+ # @example Specifying to first use the Artsy repository and then the CocoaPods Master Repository
875
+ #
876
+ # source 'https://github.com/artsy/Specs.git'
877
+ # source 'https://cdn.cocoapods.org/'
878
+ #
879
+ # @return [void]
880
+ #
881
+ def source(source)
882
+ hash_sources = get_hash_value('sources') || []
883
+ hash_sources << source
884
+ set_hash_value('sources', hash_sources.uniq)
885
+ end
886
+
887
+ #-----------------------------------------------------------------------#
888
+
451
889
  # @!group Hooks
452
890
  # The Podfile provides hooks that will be called during the
453
891
  # installation process.
@@ -456,16 +894,42 @@ module Pod
456
894
 
457
895
  #-----------------------------------------------------------------------#
458
896
 
897
+ # Specifies the plugins that should be used during installation.
898
+ #
899
+ # -----
900
+ #
901
+ # Use this method to specify a plugin that should be used during
902
+ # installation, along with the options that should be passed to the plugin
903
+ # when it is invoked.
904
+ #
905
+ # @param [String] name
906
+ # The name of the plugin.
907
+ #
908
+ # @param [Hash] options
909
+ # The optional options that should be passed to the plugin when
910
+ # its hooks are invoked.
911
+ #
912
+ # @example Specifying to use the `slather` and `cocoapods-keys` plugins.
913
+ #
914
+ # plugin 'cocoapods-keys', :keyring => 'Eidolon'
915
+ # plugin 'slather'
916
+ #
917
+ # @return [void]
918
+ #
919
+ def plugin(name, options = {})
920
+ hash_plugins = get_hash_value('plugins') || {}
921
+ (hash_plugins[name] ||= {}).merge!(options.deep_stringify_keys)
922
+ set_hash_value('plugins', hash_plugins)
923
+ end
924
+
459
925
  # This hook allows you to make any changes to the Pods after they have
460
926
  # been downloaded but before they are installed.
461
927
  #
462
- # It receives the
463
- # [`Pod::Hooks::InstallerRepresentation`](http://docs.cocoapods.org/cocoapods/pod/hooks/installerrepresentation/)
464
- # as its only argument.
928
+ # It receives the [Pod::Installer] as its only argument.
465
929
  #
466
- # @example Defining a pre install hook in a Podfile.
930
+ # @example Defining a pre-install hook in a Podfile.
467
931
  #
468
- # pre_install do |installer_representation|
932
+ # pre_install do |installer|
469
933
  # # Do something fancy!
470
934
  # end
471
935
  #
@@ -474,18 +938,34 @@ module Pod
474
938
  @pre_install_callback = block
475
939
  end
476
940
 
941
+ # This hook allows you to make changes before the project is written
942
+ # to disk.
943
+ #
944
+ # It receives the [Pod::Installer] as its only argument.
945
+ #
946
+ # @example Customizing the dependencies before integration
947
+ #
948
+ # pre_integrate do |installer|
949
+ # # perform some changes on dependencies
950
+ # end
951
+ #
952
+ # @return [void]
953
+ #
954
+ def pre_integrate(&block)
955
+ raise Informative, 'Specifying multiple `pre_integrate` hooks is unsupported.' if @pre_integrate_callback
956
+ @pre_integrate_callback = block
957
+ end
958
+
477
959
  # This hook allows you to make any last changes to the generated Xcode
478
960
  # project before it is written to disk, or any other tasks you might want
479
961
  # to perform.
480
962
  #
481
- # It receives the
482
- # [`Pod::Hooks::InstallerRepresentation`](http://docs.cocoapods.org/cocoapods/pod/hooks/installerrepresentation/)
483
- # as its only argument.
963
+ # It receives the [Pod::Installer] as its only argument.
484
964
  #
485
- # @example Customizing the `OTHER_LDFLAGS` of all targets
965
+ # @example Customizing the build settings of all targets
486
966
  #
487
- # post_install do |installer_representation|
488
- # installer_representation.project.targets.each do |target|
967
+ # post_install do |installer|
968
+ # installer.pods_project.targets.each do |target|
489
969
  # target.build_configurations.each do |config|
490
970
  # config.build_settings['GCC_ENABLE_OBJC_GC'] = 'supported'
491
971
  # end
@@ -495,8 +975,27 @@ module Pod
495
975
  # @return [void]
496
976
  #
497
977
  def post_install(&block)
978
+ raise Informative, 'Specifying multiple `post_install` hooks is unsupported.' if @post_install_callback
498
979
  @post_install_callback = block
499
980
  end
981
+
982
+ # This hook allows you to make changes after the project is written
983
+ # to disk.
984
+ #
985
+ # It receives the [Pod::Installer] as its only argument.
986
+ #
987
+ # @example Customizing the build settings of all targets
988
+ #
989
+ # post_integrate do |installer|
990
+ # # some change after project write to disk
991
+ # end
992
+ #
993
+ # @return [void]
994
+ #
995
+ def post_integrate(&block)
996
+ raise Informative, 'Specifying multiple `post_integrate` hooks is unsupported.' if @post_integrate_callback
997
+ @post_integrate_callback = block
998
+ end
500
999
  end
501
1000
  end
502
1001
  end