CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. It has over eighteen thousand libraries and can help you scale your projects elegantly. Interested in the news about Swift Package Manager? Check our FAQ
CocoaPods is built with Ruby and is installable with the default Ruby available on OS X. We recommend you use the default ruby.
Using the default Ruby install can require you to use
sudo when installing
gems. Further installation instructions are in the guides.
$ sudo gem install cocoapods
We are currently building a Mac app that hosts CocoaPods, similar to how Xcode hosts all of your usual developer tools. You can grab the latest release here.
Search for pods (above). Then list the dependencies in a text file named
Podfile in your Xcode project directory:
platform :ios, '8.0' use_frameworks! target 'MyApp' do pod 'AFNetworking', '~> 2.6' pod 'ORStackView', '~> 3.0' pod 'SwiftyJSON', '~> 2.3' end
Tip: CocoaPods provides a
pod init command to create a Podfile with
smart defaults. You should use it.
Now you can install the dependencies in your project:
$ pod install
Make sure to always open the Xcode workspace instead of the project file when building your project:
$ open App.xcworkspace
Now you can import your dependencies e.g.:
Sometimes CocoaPods doesn’t yet have a pod for one of your dependencies. Fortunately, creating a pod is pretty easy:
$ pod spec create Peanut $ edit Peanut.podspec $ pod spec lint Peanut.podspec