CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. Kinda like what npm is for Node.js and what Composer is for PHP.
1sudo gem install cocoapods
2cd project-dir
3pod init
4# edit the Podfile
5pod install
6# open the .xcworkspace file and get to work
install
1sudo gem install cocoapods
1pod setup --verbose
create an Xcode project, save it, exit Xcode.
Now open Terminal, cd
into the directory of your project, and run
1pod init
this will create a Podfile
in your project dir. This is the equivalent of package.json
fornpm
in Node. Here you should uncomment the platform :ios, '9.0'
and add the pods you want included before the end
. For example: pod 'Moltin'
1# Uncomment this line to define a global platform for your project
2platform :ios, '9.0'
3
4target 'MoltinShoppingApp' do
5 # Comment this line if you're not using Swift and don't want to use dynamic frameworks
6 use_frameworks!
7
8 # Pods for MoltinShoppingApp
9 pod 'Moltin'
10end
Save the file, close. Now run:
1pod install
to install your pods. You should see something like this:
1$ pod install
2Analyzing dependencies
3Downloading dependencies
4Installing AFNetworking (3.1.0)
5Installing Moltin (1.1.5)
6Generating Pods project
7Integrating client project
8
9[!] Please close any current Xcode sessions and use `MoltinShoppingApp.xcworkspace` for this project from now on.
10Sending stats
11Pod installation complete! There is 1 dependency from the Podfile and 2 total pods installed.
From now on, in order to access your installed projects, you should be using the .xcworkspace
file to open the Xcode project.
That’s it. Note that if your Pod is in objective-c, you might need to add a bridging header to be able to use it in your Swift project.