Learn how to integrate CocoaPods into your iOS Mobile app.
Use the following steps to set up Cocoa Pods in your project.
- Open a terminal and navigate to your project.
Run the following command to initiate CocoaPods and create the default podfile
for defining the project dependencies:
pod initThe default Podfile is created for your project.
Open the Podefile in Xcode. This can be done from the command line using the
open -a Xcode Podfile
- Open the pod file for editing.
Define the default iOS platform. The default platform is defined as 7.0 in the
following code example:
platform :ios, '7.0'Note: If the platform is not defined version 4.3 is assumed.
Define your dependencies using the following syntax:
pod 'Dependency Name' 'Dependency Version'
From the terminal run the command to install the defined dependences:
The Pods folder is not created to store the project dependencies and the project.xcworkspace is created.Important: At this point all project work must be done in the xcworkspace.
Open the project .xcworkspace.
Notice that you now have two separate projects in the workspace. Add any new files to the Xcode project and not the Pods project.
- Create new files from Xcode by navigating to File > New > File. Select iOS > Source > Cocoa Touch Class, and click Next.
- Name the class, assign it as a subclass, create the XIB file for iPhone or iPod, and click Next.
- Add the new file to the Xcode project (not the pod project) and click Create.
The project is now ready to build. Add as many pods as needed to satisfy the app dependencies and requirements. To test a complete CocoaPods Ooyala project, see Testing the Ooyala CocoaPods Tutorial.