Skip to content

Installing RestKit v0.20.x via CocoaPods

mozeryansky edited this page Jun 17, 2015 · 6 revisions

Installing RestKit v0.20.x via CocoaPods

Quick Start

  1. Update your Podfile to include pod 'RestKit', '~> 0.24.0'
  2. Update your Pre-compiled Header File to include System Configuration, Core Services (OS X) or Mobile Core Services (iOS) and Core Data (if you are working with it).

Read below for more details.

CocoaPods Overview

CocoaPods is a dependency manager for iOS. It lets you specify and manage your 3rd-party library dependencies in a single text file (called a "Podfile"). CocoaPods uses a command-line executable ("pod"), and its end result is a new .xcworkspace based on your .xcodeproj, that already has all the 3rd-party code pulled in.

The process of using CocoaPods is typically:

  1. Create a Podfile and configure library dependencies.
  2. Execute pod install.
  3. CocoaPods downloads the 3rd-party code and creates a new .xcworkspace.
  4. From now on, you use the .xcworkspace file to open your project in Xcode.

For more information on CocoaPods, see http://cocoapods.org/

Installing CocoaPods

  1. gem install cocoapods
  2. pod setup

Creating your Podfile

Create the Podfile in the root of your Xcode project directory. Here's an example Podfile pulling in the latest RestKit:

    platform :ios, '5.0'
    # platform :osx, '10.7'
    pod 'RestKit', '~>  0.20.0'

Note that if you are installing into an OS X app, you'll want to comment out the :ios platform declaration and enable the :osx platform declaration instead.

Running pod install

Do this from the root of your Xcode project directory, where your Podfile is.

  1. pod install

You should now have a '.xcworkspace' file within your project directory. You will use this workspace going forward instead of the '.xcodeproj' file.

Adding Frameworks to the Precompiled Header File

Open your project's precompiled header file within Xcode. This file is generally named after your project and has a '.pch' suffix. Add the following lines:

#import <Availability.h>
#if __IPHONE_OS_VERSION_MIN_REQUIRED
  #import <SystemConfiguration/SystemConfiguration.h>
  #import <MobileCoreServices/MobileCoreServices.h>
#else
  #import <SystemConfiguration/SystemConfiguration.h>
  #import <CoreServices/CoreServices.h>
#endif

// If using Core Data, you may also wish to append
#import <CoreData/CoreData.h>

In case you still get errors and the Build fails, follow the following steps:

  1. In the Project Navigator on the left in your Xcode, click on the name of the project.
  2. Click on the name of your app in the 'Targets' header.
  3. Click on the 'Build Phases' tab.
  4. Expand the 'Link Binary With Libraries' and make sure you've added the following list of frameworks in case they are already not their in the list:
    • MobileCoreServices.framework
    • Security.framework
    • CFNetwork.framework
    • SystemConfiguration.framework
    • CoreData.framework
    • UIKit.framework
    • Foundation.framework
    • CoreGraphics.framework

Troubleshooting

If you run into any issues with a CocoaPods based installation out of the box the most likely cause is that project or target contains configuration that is overriding the settings provided via CocoaPods. CocoaPods works by adding a .xcconfig file that contains configuration aggregated from the Pods you have installed. If you augment these configuration settings within your target, you have to be sure to include the $(inherited) value to pick up the values provided by CocoaPods.

Please be check the following settings for overridden configuration and add the $(inherited) if necessary:

  1. OTHER_LDFLAGS
  2. HEADER_SEARCH_PATHS