Configuring an Xcode Project
Xcode is the defacto Integrated Development Environment (IDE) for developing iOS applications. Xcode can be downloaded separately or as part of the iOS SDK from Apple's iOS Dev Center. Both Xcode 3.2 and Xcode 4 are supported. At the time of writing this document, Xcode 4.2 was the most recent version available and supported.
You can create a new project using one of the built-in iOS project templates and then configure it to begin development with ArcGIS Runtime SDK for iOS.The following steps describe the project settings that need to be configured.
Some of you may notice that ArcGIS specific Xcode project templates are no longer available. This is because 3rd party project templates are not officially supported by Xcode.
1. Add ArcGIS library
Xcode 4
To add the ArcGIS library to your project, select the project node in the left Navigator pane, select a target node, and choose the Build Phases tab. Under the Link Binary with Libraries section, click on the + button to add the ArcGIS library.
The ArcGIS library is not in the default list of iOS libraries so you will need to click the Add Other... button to browse for the library. The library is typically located at ${HOME} /Library/SDKs/ArcGIS/iOS.sdk/usr/local/lib if you picked the default location while installing the ArcGIS Runtime SDK for iOS.
The ${HOME}/Library folder is hidden by default in Mac OS X Lion. You can issue the command chflags nohidden ~/Library/ in the terminal to unhide it.
Xcode 3
To add the ArcGIS library to your project, choose the the Edit Active Target <Project_Name> options from the Project menu. This should open the Target Info window.
From within the Target Info window, select the General tab. Press the + button under the Linked Libraries section to add the ArcGIS library.
The ArcGIS library is not in the default list of iOS libraries so you will need to click the Add Other... button to browse for the library. The library is typically located at ${HOME} /Library/SDKs/ArcGIS/iOS.sdk/usr/local/lib if you installed the ArcGIS API in the default location.
2. Modify the build path
If you're using Xcode 4.2, you can skip this step. Xcode would have automatically configured the build path for you when you added the ArcGIS library in the previous step.
Adding the ArcGIS library to your project references is not enough. You also need to provide the path to this library so that your project can be built correctly.
Xcode 4
Under the Build Settings tab, type "Library Search Paths" in the Search bar to quickly find the Library Search Paths setting. Double click in the empty space under the target column, and use the plus button to add the following entry:
$(HOME)/Library/SDKs/ArcGIS/iOS.sdk/usr/local/lib
Xcode 3
Open the Target Info window once again except this time select the Build tab. Scroll down to the Library Search Paths, double click on it, and use the plus button to add the following entry:
$(HOME)/Library/SDKs/ArcGIS/iOS.sdk/usr/local/lib
3. Add dependent libraries
The ArcGIS library in turn depends upon the following frameworks and libraries which need to be added to your project's settings.
- CoreGraphics.framework
- CoreLocation.framework
- Foundation.framework
- QuartzCore.framework
- UIKit.framework
- CoreText.framework (dependency introduced at v1.8)
- libstdc++.dylib (dependency introduced at v1.8)
- MediaPlayer.framework (dependency introduced at v2.0)
- MobileCoreServices.framework (dependency introduced at v2.0)
- libz.dylib (dependency introduced at v2.1)
- Security.framework (dependency introduced at v2.1)
Xcode 4
Select the Build Phases tab. Under the Link Binary with Libraries section, click on the + button, select and add each dependency.
Xcode 3
Select the Edit Active Target <Project_Name> option from the Project menu. This should open the Target Info window. From within the Target Info window, select the General tab. Click on the + button under the Linked Libraries section, select and add each dependency.
4. Modify build flags
ArcGIS library is an Objective-C library. You need to add some build flags to your project to ensure that the Objective-C categories defined in the library are loaded correctly.
Without these flags, your application may crash while trying to use classes from the ArcGIS API.
Xcode 4
Under the Build Settings tab, type "Other Linker Flags" in the Search bar to quickly find the Other Linker Flags setting. Double click in the empty space under the target column, and use the plus button to add the following entries : -all_load and -ObjC . Click Done when you are finished.
Xcode 3
To add the flags, open the Target Info window, Click on the Build tab and in the Search bar type "Other Linker Flags" to quickly find the linker flag properties. Once located, double-click on it to change its properties.
Press the plus button to add the following linker flags: -all_load and -ObjC. Click Ok when you are done.
5. Add ArcGIS header files to the search path
Xcode 4
Under the Build Settings tab, type "User Header Search Paths" in the Search bar to quickly find the User Header Search Paths setting. Double click in the empty space under the target column, and use the plus button to add the following entry:
$(HOME)/Library/SDKs/ArcGIS/iOS.sdk/usr/local/include/**
Xcode 3
From within the Target Info window, you will need to add the header files to the search path to support the ArcGIS library.
Click on the Build tab and in the Search bar type "User Header Search Paths". Once located, double-click on it to change its properties.
Press the plus button to add the following path:
$(HOME)/Library/SDKs/ArcGIS/iOS.sdk/usr/local/include/**
6. Add Resource Bundle
API resources such as images for the Esri and Bing logo, GPS location, etc have been consolidated into an ArcGIS.bundle file. This bundle is installed under ${HOME}/Library/SDKs/ArcGIS/iOS.sdk/user/local/resources. You need to manually add it to your project as described below.
To use custom images instead of the ones provided with bundle, add the custom images to your project making sure they have the same name as the images in the bundle. Images in your project will take precedence over those in the bundle.
Xcode 4
Go to the XCode application's File menu, select the Add Files to <project> item, browse to the location ${HOME}/Library/SDKs/ArcGIS/iOS.sdk/user/local/resources, select the ArcGIS.bundle file, and click Add.
XCode 3
Go to the XCode application's Project menu, select the Add to project item, browse to the location ${HOME}/Library/SDKs/ArcGIS/iOS.sdk/user/local/resources, select the ArcGIS.bundle file, click Add, and then click Add again.
Now that you have configured an Xcode project to begin development withArcGIS Runtime SDK for iOS, the next step is to create a map to display in your application.
Configuring a new project as described above can be a little tedious, especially if you have to do it repeatedly. For your convenience, we provide a pre-configured project with the SDK installed under ${HOME}/Library/SDKs/Samples/MapViewDemo. This sample is minimal and only contains the code to display a full screen map. You can easily make a copy of this project and then rename it to quickly begin development on a new application.