>DSL

DSL

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

pod

podspec

target

Target configuration

platform

xcodeproj

link_with

inhibit_all_warnings!

Workspace

workspace

generate_bridge_support!

set_arc_compatibility_flag!

Hooks

pre_install

post_install

pod

Signature

pod(name = nil, *requirements, &block) #=> void 

Returns

void

Source

149 def pod(name = nil, *requirements, &block)
150   if block
151     raise StandardError, "Inline specifications are deprecated. Please store the specification in a `podspec` file."
152   end
153 
154   unless name
155     raise StandardError, "A dependency requires a name."
156   end
157 
158   current_target_definition.store_pod(name, *requirements)
159 end

Source Files

lib/cocoapods-core/podfile/dsl.rb:149

spec/podfile/dsl_spec.rb

spec/specification/dsl_spec.rb

podspec

Signature

podspec(options = nil) #=> void 

Parameters

Hash {Symbol=>String} options

The path where to load the Specification. If not provided the first podspec in the directory of the podfile is used.

Returns

void


Examples:

podspec

podspec :name => 'QuickDialog'

podspec :path => '/Documents/PrettyKit/PrettyKit.podspec'

Source

193 def podspec(options = nil)
194   current_target_definition.store_podspec(options)
195 end

Source Files

lib/cocoapods-core/podfile/dsl.rb:193

spec/podfile/dsl_spec.rb

spec/specification/dsl_spec.rb

target

Signature

target(name, options = {}) #=> void 

Parameters

Symbol String name

The name of the target definition.

Hash options

A customizable set of options

Returns

void


Examples:

Defining a target

target :ZipApp do
  pod 'SSZipArchive'
end

Defining an exclusive target

target :ZipApp do
  pod 'SSZipArchive'
  target :test, :exclusive => true do
    pod 'JSONKit'
  end
end

Source

232 def target(name, options = {})
233   if options && !options.keys.all? { |key| [:exclusive].include?(key) }
234     raise Informative, "Unsupported options `#{options}` for target `#{name}`"
235   end
236 
237   parent = current_target_definition
238   definition = TargetDefinition.new(name, parent)
239   definition.exclusive = true if options[:exclusive]
240   self.current_target_definition = definition
241   yield
242 ensure
243   self.current_target_definition = parent
244 end

Source Files

lib/cocoapods-core/podfile/dsl.rb:232

spec/podfile/dsl_spec.rb

spec/specification/dsl_spec.rb

platform

Signature

platform(name, target = nil) #=> void 

Parameters

Symbol name

The name of platform, can be either :osx for OS X or :ios for iOS.

String Version target

The optional deployment. If not provided a default value according to the platform name will be assigned.

Returns

void


Examples:

Specifying the platform

platform :ios, "4.0"
platform :ios

Source

280 def platform(name, target = nil)
281   # Support for deprecated options parameter
282   target = target[:deployment_target] if target.is_a?(Hash)
283   current_target_definition.set_platform(name, target)
284 end

Source Files

lib/cocoapods-core/podfile/dsl.rb:280

spec/podfile/dsl_spec.rb

spec/specification/dsl_spec.rb

xcodeproj

Signature

xcodeproj(path, build_configurations = {}) #=> void 

Parameters

String path

The path of the project to link with

Hash{String => symbol} build_configurations

A hash where the keys are the name of the build configurations in your Xcode project and the values are Symbols that specify if the configuration should be based on the :debug or :release configuration. If no explicit mapping is specified for a configuration in your project, it will default to :release.

Returns

void


Examples:

Specifying the user project

# Look for target to link with in an Xcode project called
# `MyProject.xcodeproj`.
xcodeproj `MyProject`

target :test do
  # This Pods library links with a target in another project.
  xcodeproj `TestProject`
end

Using custom build configurations

xcodeproj `TestProject`, 'Mac App Store' => :release, 'Test' => :debug

Source

331 def xcodeproj(path, build_configurations = {})
332   current_target_definition.user_project_path = path
333   current_target_definition.build_configurations = build_configurations
334 end

Source Files

lib/cocoapods-core/podfile/dsl.rb:331

spec/podfile/dsl_spec.rb

spec/specification/dsl_spec.rb

inhibit_all_warnings!

Signature

inhibit_all_warnings! #=> undefined

Source

373 def inhibit_all_warnings!
374   current_target_definition.inhibit_all_warnings = true
375 end

Source Files

lib/cocoapods-core/podfile/dsl.rb:373

spec/podfile/dsl_spec.rb

spec/specification/dsl_spec.rb

workspace

Signature

workspace(path) #=> void 

Parameters

String path

Path of the workspace.

Returns

void


Examples:

Specifying a workspace

workspace 'MyWorkspace'

Source

403 def workspace(path)
404   set_hash_value('workspace', path.to_s)
405 end

Source Files

lib/cocoapods-core/podfile/dsl.rb:403

spec/podfile/dsl_spec.rb

spec/specification/dsl_spec.rb

generate_bridge_support!

Signature

generate_bridge_support! #=> void 

Returns

void

Source

419 def generate_bridge_support!
420   set_hash_value('generate_bridge_support', true)
421 end

Source Files

lib/cocoapods-core/podfile/dsl.rb:419

spec/podfile/dsl_spec.rb

spec/specification/dsl_spec.rb

set_arc_compatibility_flag!

Signature

set_arc_compatibility_flag! #=> void 

Returns

void

Source

437 def set_arc_compatibility_flag!
438   set_hash_value('set_arc_compatibility_flag', true)
439 end

Source Files

lib/cocoapods-core/podfile/dsl.rb:437

spec/podfile/dsl_spec.rb

spec/specification/dsl_spec.rb

pre_install

Signature

pre_install(&block) #=> undefined

Examples:

Defining a pre install hook in a Podfile.

pre_install do |installer_representation|
  # Do something fancy!
end

Source

465 def pre_install(&block)
466   @pre_install_callback = block
467 end

Source Files

lib/cocoapods-core/podfile/dsl.rb:465

spec/podfile/dsl_spec.rb

spec/specification/dsl_spec.rb

post_install

Signature

post_install(&block) #=> void 

Returns

void


Examples:

Customizing the `OTHER_LDFLAGS` of all targets

post_install do |installer_representation|
  installer_representation.project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['GCC_ENABLE_OBJC_GC'] = 'supported'
    end
  end
end

Source

489 def post_install(&block)
490   @post_install_callback = block
491 end

Source Files

lib/cocoapods-core/podfile/dsl.rb:489

spec/podfile/dsl_spec.rb

spec/specification/dsl_spec.rb