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
pod
podspec
target
platform
xcodeproj
link_with
inhibit_all_warnings!
workspace
generate_bridge_support!
set_arc_compatibility_flag!
pre_install
post_install
pod(name = nil, *requirements, &block) #=> void
void
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
podspec(options = nil) #=> void
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.
void
podspec
podspec :name => 'QuickDialog'
podspec :path => '/Documents/PrettyKit/PrettyKit.podspec'
193 def podspec(options = nil)
194 current_target_definition.store_podspec(options)
195 end
target(name, options = {}) #=> void
Symbol
String
name
The name of the target definition.
Hash
options
A customizable set of options
void
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
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
platform(name, target = nil) #=> void
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.
void
Specifying the platform
platform :ios, "4.0"
platform :ios
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
xcodeproj(path, build_configurations = {}) #=> void
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
.
void
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
331 def xcodeproj(path, build_configurations = {})
332 current_target_definition.user_project_path = path
333 current_target_definition.build_configurations = build_configurations
334 end
link_with(targets) #=> void
String
Array<String>
targets
The target or the targets to link with.
void
Link with an user project target
link_with 'MyApp'
Link with a more user project targets
link_with ['MyApp', 'MyOtherApp']
358 def link_with(targets)
359 current_target_definition.link_with = targets
360 end
inhibit_all_warnings! #=> undefined
373 def inhibit_all_warnings!
374 current_target_definition.inhibit_all_warnings = true
375 end
workspace(path) #=> void
String
path
Path of the workspace.
void
Specifying a workspace
workspace 'MyWorkspace'
403 def workspace(path)
404 set_hash_value('workspace', path.to_s)
405 end
generate_bridge_support! #=> void
void
419 def generate_bridge_support!
420 set_hash_value('generate_bridge_support', true)
421 end
set_arc_compatibility_flag! #=> void
void
437 def set_arc_compatibility_flag!
438 set_hash_value('set_arc_compatibility_flag', true)
439 end
pre_install(&block) #=> undefined
Defining a pre install hook in a Podfile.
pre_install do |installer_representation|
# Do something fancy!
end
465 def pre_install(&block)
466 @pre_install_callback = block
467 end
post_install(&block) #=> void
void
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
489 def post_install(&block)
490 @post_install_callback = block
491 end