Module: Pod::Podfile::DSL
- Included in:
- Pod::Podfile
- Defined in:
- lib/cocoapods-core/podfile/dsl.rb
Overview
The Podfile is a specification that describes the dependencies of the targets of one or more Xcode projects. The Podfile always creates an implicit target, named ‘default`, which links to the first target of the user project.
A podfile can be very simple:
pod 'AFNetworking', '~> 1.0'
An example of a more complex podfile can be:
platform :ios, '6.0'
inhibit_all_warnings!
xcodeproj 'MyProject'
pod 'ObjectiveSugar', '~> 0.5'
target :test do
pod 'OCMock', '~> 2.0.1'
end
post_install do |installer|
installer.project.targets.each do |target|
puts "#{target.name}"
end
end
Dependencies The Podfile specifies the dependencies of each user target. * `pod` is the way to declare a specific dependency. * `podspec` provides an easy API for the creation of podspecs. * `target` allows you to scope your dependencies to specific targets in your Xcode projects. collapse
- #pod(name = nil, *requirements, &block) ⇒ void
-
#podspec(options = nil) ⇒ void
Use the dependencies of a Pod defined in the given podspec file.
-
#target(name, options = {}) ⇒ void
Defines a new static library target and scopes dependencies defined from the given block.
Target configuration These settings are used to control the CocoaPods generated project. This starts out simply with stating what `platform` you are working on. `xcodeproj` allows you to state specifically which project to link with. collapse
-
#inhibit_all_warnings! ⇒ Object
Inhibits all the warnings from the CocoaPods libraries.
-
#link_with(*targets) ⇒ void
Specifies the target(s) in the user’s project that this Pods library should be linked in.
-
#platform(name, target = nil) ⇒ void
Specifies the platform for which a static library should be build.
-
#xcodeproj(path, build_configurations = {}) ⇒ void
Specifies the Xcode project that contains the target that the Pods library should be linked with.
Workspace This group list the options to configure workspace and to set global settings. collapse
-
#generate_bridge_support! ⇒ void
Specifies that a BridgeSupport metadata document should be generated from the headers of all installed Pods.
-
#set_arc_compatibility_flag! ⇒ void
Specifies that the -fobjc-arc flag should be added to the ‘OTHER_LD_FLAGS`.
-
#workspace(path) ⇒ void
Specifies the Xcode workspace that should contain all the projects.
Hooks The Podfile provides hooks that will be called during the installation process. Hooks are __global__ and not stored per target definition. collapse
-
#post_install(&block) ⇒ void
This hook allows you to make any last changes to the generated Xcode project before it is written to disk, or any other tasks you might want to perform.
-
#pre_install(&block) ⇒ Object
This hook allows you to make any changes to the Pods after they have been downloaded but before they are installed.
Instance Method Details
#generate_bridge_support! ⇒ void
This method returns an undefined value.
Specifies that a BridgeSupport metadata document should be generated from the headers of all installed Pods.
This is for scripting languages such as [MacRuby](macruby.org), [Nu](programming.nu/index), and [JSCocoa](inexdo.com/JSCocoa), which use it to bridge types, functions, etc.
427 428 429 |
# File 'lib/cocoapods-core/podfile/dsl.rb', line 427 def generate_bridge_support! set_hash_value('generate_bridge_support', true) end |
#inhibit_all_warnings! ⇒ Object
Inhibits all the warnings from the CocoaPods libraries.
This attribute is inherited by child target definitions.
If you would like to inhibit warnings per Pod you can use the following syntax:
pod 'SSZipArchive', :inhibit_warnings => true
381 382 383 |
# File 'lib/cocoapods-core/podfile/dsl.rb', line 381 def inhibit_all_warnings! current_target_definition.inhibit_all_warnings = true end |
#link_with(*targets) ⇒ void
This method returns an undefined value.
Specifies the target(s) in the user’s project that this Pods library should be linked in.
If no explicit target is specified, then the Pods target will be linked with the first target in your project. So if you only have one target you do not need to specify the target to link with.
366 367 368 |
# File 'lib/cocoapods-core/podfile/dsl.rb', line 366 def link_with(*targets) current_target_definition.link_with = targets.flatten end |
#platform(name, target = nil) ⇒ void
This method returns an undefined value.
Specifies the platform for which a static library should be build.
CocoaPods provides a default deployment target if one is not specified. The current default values are ‘4.3` for iOS and `10.6` for OS X.
If the deployment target requires it (iOS < ‘4.3`), `armv6` architecture will be added to `ARCHS`.
288 289 290 291 292 |
# File 'lib/cocoapods-core/podfile/dsl.rb', line 288 def platform(name, target = nil) # Support for deprecated options parameter target = target[:deployment_target] if target.is_a?(Hash) current_target_definition.set_platform(name, target) end |
#pod(name = nil, *requirements, &block) ⇒ void
This method returns an undefined value.
152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/cocoapods-core/podfile/dsl.rb', line 152 def pod(name = nil, *requirements, &block) if block raise StandardError, 'Inline specifications are deprecated. ' \ 'Please store the specification in a `podspec` file.' end unless name raise StandardError, 'A dependency requires a name.' end current_target_definition.store_pod(name, *requirements) end |
#podspec(options = nil) ⇒ void
This method uses the dependencies declared by the for the platform of the target definition.
This method requires that the Podfile has a non nil value for Pod::Podfile#defined_in_file unless the path option is used.
This method returns an undefined value.
Use the dependencies of a Pod defined in the given podspec file. If no arguments are passed the first podspec in the root of the Podfile is used. It is intended to be used by the project of a library. Note: this does not include the sources derived from the podspec just the CocoaPods infrastructure.
199 200 201 |
# File 'lib/cocoapods-core/podfile/dsl.rb', line 199 def podspec( = nil) current_target_definition.store_podspec() end |
#post_install(&block) ⇒ void
This method returns an undefined value.
This hook allows you to make any last changes to the generated Xcode project before it is written to disk, or any other tasks you might want to perform.
It receives the [‘Pod::Hooks::InstallerRepresentation`](docs.cocoapods.org/cocoapods/pod/hooks/installerrepresentation/) as its only argument.
497 498 499 |
# File 'lib/cocoapods-core/podfile/dsl.rb', line 497 def post_install(&block) @post_install_callback = block end |
#pre_install(&block) ⇒ Object
This hook allows you to make any changes to the Pods after they have been downloaded but before they are installed.
It receives the [‘Pod::Hooks::InstallerRepresentation`](docs.cocoapods.org/cocoapods/pod/hooks/installerrepresentation/) as its only argument.
473 474 475 |
# File 'lib/cocoapods-core/podfile/dsl.rb', line 473 def pre_install(&block) @pre_install_callback = block end |
#set_arc_compatibility_flag! ⇒ void
This method returns an undefined value.
Specifies that the -fobjc-arc flag should be added to the ‘OTHER_LD_FLAGS`.
This is used as a workaround for a compiler bug with non-ARC projects (see #142). This was originally done automatically but libtool as of Xcode 4.3.2 no longer seems to support the ‘-fobjc-arc` flag. Therefore it now has to be enabled explicitly using this method.
Support for this method might be dropped in CocoaPods ‘1.0`.
445 446 447 |
# File 'lib/cocoapods-core/podfile/dsl.rb', line 445 def set_arc_compatibility_flag! set_hash_value('set_arc_compatibility_flag', true) end |
#target(name, options = {}) ⇒ void
This method returns an undefined value.
Defines a new static library target and scopes dependencies defined from the given block. The target will by default include the dependencies defined outside of the block, unless the ‘:exclusive => true` option is given.
The Podfile creates a global target named ‘:default` which produces the `libPods.a` file. This target is linked with the first target of user project if not value is specified for the `link_with` attribute.
239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/cocoapods-core/podfile/dsl.rb', line 239 def target(name, = {}) if && !.keys.all? { |key| [:exclusive].include?(key) } raise Informative, "Unsupported options `#{options}` for " \ "target `#{name}`" end parent = current_target_definition definition = TargetDefinition.new(name, parent) definition.exclusive = true if [:exclusive] self.current_target_definition = definition yield ensure self.current_target_definition = parent end |
#workspace(path) ⇒ void
This method returns an undefined value.
Specifies the Xcode workspace that should contain all the projects.
If no explicit Xcode workspace is specified and only one project exists in the same directory as the Podfile, then the name of that project is used as the workspace’s name.
411 412 413 |
# File 'lib/cocoapods-core/podfile/dsl.rb', line 411 def workspace(path) set_hash_value('workspace', path.to_s) end |
#xcodeproj(path, build_configurations = {}) ⇒ void
This method returns an undefined value.
Specifies the Xcode project that contains the target that the Pods library should be linked with.
If no explicit project is specified, it will use the Xcode project of the parent target. If none of the target definitions specify an explicit project and there is only one project in the same directory as the Podfile then that project will be used.
It is possible also to specify whether the build settings of your custom build configurations should be modeled after the release or the debug presets. To do so you need to specify a hash where the name of each build configuration is associated to either ‘:release` or `:debug`.
339 340 341 342 |
# File 'lib/cocoapods-core/podfile/dsl.rb', line 339 def xcodeproj(path, build_configurations = {}) current_target_definition.user_project_path = path current_target_definition.build_configurations = build_configurations end |