1. Synopsis

CocoaPods is the dependency manager for Objective-C projects. It is similar to RubyGems and Bundler, but for Objective-C dependencies.

Dependencies in CocoaPods are called Pods. You can get the list of available Pods available and more information from http://cocoapods.org.

CocoaPods was originally designed to be integrated in Objective-C Xcode projects, but we worked with the awesome CocoaPods author to make it possible to be used in RubyMotion projects.

2. Installation

First, you will need to install and setup CocoaPods. Please refer to the installation guide on how to install CocoaPods, then run:

$ pod setup

The RubyMotion CocoaPods integration also comes as a gem and can be installed as follows:

$ sudo gem install motion-cocoapods

3. Usage

You will need to require the gem inside the Rakefile of your project.

require 'rubygems'
require 'motion-cocoapods'

Once you do that, you can simply use the pods method of the application configuration object to describe the Pods you want to require, by using the same expressions as you would do in a regular Podfile.

For instance, if you want to make use of the AFNetworking Pod:

Motion::Project::App.setup do |app|
  # ...
  app.pods do
    pod 'AFNetworking'

Then you only need to tell your project to run the CocoaPods integration which will download the sources and configure your project to include AFNetworking on the next build:

$ rake pod:install

Now when you build your project, the AFNetworking sources will be built and linked against your application executable:

$ rake
     Build ./build/iPhoneSimulator-7.1-Development
     Build ./vendor/Pods/Pods.xcodeproj [AFNetworking - Release]
   Compile ./vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperation.m
   Compile ./vendor/Pods/AFNetworking/AFNetworking/AFHTTPRequestOperationManager.m
   Compile ./vendor/Pods/AFNetworking/AFNetworking/AFHTTPSessionManager.m
   Compile ./vendor/Pods/AFNetworking/UIKit+AFNetworking/AFNetworkActivityIndicatorManager.m
   Compile ./vendor/Pods/AFNetworking/AFNetworking/AFNetworkReachabilityManager.m
   Compile ./vendor/Pods/AFNetworking/AFNetworking/AFSecurityPolicy.m
   Compile ./vendor/Pods/AFNetworking/AFNetworking/AFURLConnectionOperation.m
   Compile ./vendor/Pods/AFNetworking/AFNetworking/AFURLRequestSerialization.m
   Compile ./vendor/Pods/AFNetworking/AFNetworking/AFURLResponseSerialization.m
   Compile ./vendor/Pods/AFNetworking/AFNetworking/AFURLSessionManager.m
      Link ./vendor/Pods/.build/libPods-AFNetworking.a
     Build ./vendor/Pods/Pods.xcodeproj [Pods - Release]
      Link ./vendor/Pods/.build/libPods.a