CocoaPods is a popular dependency manager for Swift and Objective-C projects, will resolve dependencies between libraries, fetch the resulting source code, then link it together in an Xcode workspace to build your project.
CocoaPods uses a centralized Podspecs repository has over 91 thousand libraries and is used in over 3 million apps.
CocoaPods supports almost every way you would want to get source code; git, svn, bzr, http and hg. You can use your own private code repository to manage your own dependencies. It only requires a git repo, no server necessary.
# Might require you to use sudo when installing
$ sudo gem install cocoapods
# To update CocoaPods you simply install the gem again
$ [sudo] gem install cocoapods
# Or for a pre-release version
$ [sudo] gem install cocoapods --prePodfile, and add your dependencies.pod install in your project directory.AppName.xcworkspace and build.Note that CocoaPods itself does not require the use of a workspace. If you prefer to use sub-projects, you can do so by running pod install --no-integrate, which will leave integration into your project up to you as you see fit.
Whether or not you check in the Pods directory, the Podfile and Podfile.lock should always be kept under version control.
The Podfile is a specification that describes the dependencies of the targets of one or more Xcode projects. An example of a more complex Podfile can be:
platform :ios, '9.0'
inhibit_all_warnings!
target 'MyApp' do
pod 'ObjectiveSugar', '~> 0.5'
pod 'SSZipArchive'
pod 'Objection', '0.9'
target 'MyAppTests' do
inherit! :search_paths
pod 'OCMock', '~> 2.0.1'
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
puts "#{target.name}"
end
endSpecifying pod versions using logical operators or optimistic operator ~> regarding semantic versioning.
> 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 version~> 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 higherThis file is generated after the first run of pod install, and tracks the version of each Pod that was installed.
CocoaPods will honour the Pod version in Podfile.lock unless the dependency is updated in the Podfile or pod update is called (which will cause a new Podfile.lock to be generated). In this way CocoaPods avoids headaches caused by unexpected changes to dependencies.
Whether or not you check in your Pods folder is up to you, as workflows vary from project to project. Ultimately this decision is up to you:
Benefits of checking in the Pods directory:
pod install, and no Internet connection is necessary.Benefits of ignoring the Pods directory:
Podfile. This is especially true when using zip files in the Podfile.)