The Podfile is a specification that describes the dependencies of thetargets of one or more Xcode projects. The file should simply be namedPodfile.All the examples in the guides are based on CocoaPods version 1.0 and onwards.
A Podfile can be very simple, this adds Alamofire to a single target:
An example of a more complex Podfile linking an app and its test bundle:
If you want multiple targets to share the same pods, use an
abstract_target.
There is implicit abstract target at the root of the Podfile, so you could write the above example as:
We have ablog post explaining the changes in depth.
When starting out with a project it is likely that you will want to use the latest version of a Pod. If this is the case, simply omit the version requirements.
Later on in the project you may want to freeze to a specific version of a Pod, in which case you can specify that version number.
Besides no version, or a specific one, it is also possible to use logical operators:
'> 0.1' Any version higher than 0.1'>= 0.1' Version 0.1 and any higher version'< 0.1' Any version lower than 0.1'<= 0.1' Version 0.1 and any lower versionIn addition to the logic operators CocoaPods has an optimistic operator~>:
'~> 0.1.2' Version 0.1.2 and the versions up to 0.2, not including 0.2 and higher'~> 0.1' Version 0.1 and the versions up to 1.0, not including 1.0 and higher'~> 0' Version 0 and the versions up to 1.0, not including 1.0 and higherFor more information, regarding versioning policy, see:
~> 1 in the video is incorrect.If you would like to develop a Pod in tandem with its clientproject you can use
:path.
Using this option CocoaPods will assume the given folder to be theroot of the Pod and will link the files directly from there in thePods project. This means that your edits will persist between CocoaPodsinstallations. The referenced folder can be a checkout of your favourite SCM oreven a git submodule of the current repo.
Note that thepodspec of the Pod file is expected to be in that the designated folder.
Sometimes you may want to use the bleeding edge version of a Pod, aspecific revision or your own fork. If this is the case, you can specify that with yourpod declaration.
To use the
masterbranch of the repo:
To use a different branch of the repo:
To use a tag of the repo:
Or specify a commit:
It is important to note, though, that this means that the version willhave to satisfy any other dependencies on the Pod by other Pods.
Thepodspec file is expected to be in the root of the repo, if thislibrary does not have apodspec file in its repo yet, you will haveto use one of the approaches outlined in the sections below.