Installation for ArcGIS Runtime SDK for iOS with CocoaPods

Blog Post created by Yue_Wu-esristaff Employee on Jan 7, 2015

Are you tired of implementing and managing different third-party libraries when creating your own applications? This blog shows you how to implement CocoaPods with Xcode 6.1 and use CocoaPods to download ArcGIS Runtime SDK for iOS.

CocoaPods is the dependency manager for Cocoa projects. CocoaPods has thousands of libraries and can help you elegantly scale your projects. As we all know, configuring OSX and iOS projects can be a challenging process. With CocoaPods, you can easily organize dependencies (a.k.a. pods) for the various third-party libraries used in your projects. For more information about installing CocoaPods, use this Getting Started guide as a reference. First, let’s create a new project and add a new file into your project by using the following steps. Right-click the project name, and click New File.

Select the Empty template file, and name the file "Podfile". Note: We need a file named “Podfile” because it is a specification that describes the dependencies of the targets of one or more Xcode projects. “Podfile” always creates an implicit target, which is named by default, and links to the first target of the user's project. Tip: CocoaPods provides a pod init command to create a "Podfile" with smart defaults, which you can run in a terminal as an alternative. Add the lines below into the “Podfile”, and save the file.

source 'https://github.com/CocoaPods/Specs.git' platform :ios, '8.1'  pod 'ArcGIS-Runtime-SDK-iOS', '10.2.4'

For more information about how to write a “Podfile”, please use the information listed here. After creating the "Podfile", open 'terminal.app' on the OSX machine. Navigate to the project's root folder by using the syntax below.

cd /Users/yourUsername/yourProjectFolder/

Note: As an alternative to the step above, you may also directly drag your project's main folder to the terminal. It will automatically generate the path of the folder; then, under your project folder, use the following command.

$pod setup

A successful installation displays a message similar to the screenshot below.

After the setup, we need to install the dependencies in your project. This downloads the ArcGIS framework to your machine and moves the framework into your project's Pod directory. This installation also makes the necessary changes to your project's build settings to correctly reference the ArcGIS framework.

$pod install

We can now go back to the project folder, but open the Xcode workspace instead of the project file when building your project.
The last step is to open the project workspace (*.xcworkspace file) and add the import statement '#import "<ArcGIS/ArcGIS.h>" to any Objective-C header (.h) or implementation (.m) file where you want to use the API.    
In conclusion, remember that the advantage of using CocoaPods is that you can manage dependencies easily. As a result of implementing CocoaPods, you can add additional libraries by adding other pods into the “Podfile” and run the pod install command to commit your changes to the “Podfile”.
Nathan W. & Rachel G. - SDK Support Analysts