CocoaPods and Salesforce Mobile SDK If you’re looking for a quick way to add Salesforce Mobile SDK to your existing iOS native app, we’ve got good news.

Starting with Mobile SDK 3.0–and with improvements in 3.1–you can now use CocoaPods to merge Mobile SDK modules into your apps. No more tedious downloading, copying, and reconfiguring. CocoaPods does it all for you.

The Mobile SDK podspec defines a master spec named SalesforceMobileSDK-iOS that you can use to merge the entire
Mobile SDK. The podspec also includes a subspec for each individual SDK module. When you use a subspec for merging, CocoaPods automatically pulls in all dependent modules.

Before you attempt to use CocoaPods, make sure you’ve installed the cocoapods Ruby gem as described at www.cocoapods.org. Then, follow these steps:

  1. If you don’t already have a Podfile for your project, create one in the project’s root directory. A Podfile is simply a text file named Podfile.
  2. Open your Podfile in a text editor and add a pod command that references a Mobile SDK podspec. For example, to add all modules to your app, use the following pod command:
    pod 'SalesforceMobileSDK-iOS'
  3. Open a Terminal window and run pod install from your project directory.

That’s it! CocoaPods downloads the dependencies for your requested pods and merges them into your project. Most importantly, CocoaPods creates an Xcode workspace that contains the newly merged project. After merging, you must access your project only through this .xcworkspace file–not through your original .xcodeproj file.

For important post-merge coding tips and a list of Mobile SDK subspecs, see https://developer.salesforce.com/docs/atlas.en-us.mobile_sdk.meta/mobile_sdk/ios_cocoapods.htm. If you’ve never heard of or used CocoaPods, start by reading the documentation at www.cocoapods.org.

Get the latest Salesforce Developer blog posts and podcast episodes via Slack or RSS.

Add to Slack Subscribe to RSS