Using CocoaPods

Learn how to integrate CocoaPods into your iOS Mobile app.

Use the following steps to set up Cocoa Pods in your project.

  1. Open a terminal and navigate to your project.
  2. Run the following command to initiate CocoaPods and create the default podfile for defining the project dependencies:
    pod init
    The default Podfile is created for your project.
  3. Open the Podefile in Xcode. This can be done from the command line using the following syntax:
    open -a Xcode Podfile
  4. Open the pod file for editing.
  5. 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.
  6. Define your dependencies using the following syntax:
    pod 'Dependency Name' 'Dependency Version'
  7. From the terminal run the command to install the defined dependences:
    pod install

    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.
  8. 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.

  9. Create new files from Xcode by navigating to File > New > File. Select iOS > Source > Cocoa Touch Class, and click Next. Select Cocoa Touch Template
  10. Name the class, assign it as a subclass, create the XIB file for iPhone or iPod, and click Next. Create XIB File
  11. 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.

해당 내용이 도움 되었습니까?