Creating a New 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.0.2 was the most recent version available and supported.

NoteNote:

Beta and Developer Preview versions of XCode are not supported

When you create a new iOS project in Xcode, you can start by using one of the default iOS application project templates or you can choose from one of the ArcGIS project templates that have been provided for you when you installed the ArcGIS API for iOS.

XCode 4

Using ArcGIS Project Templates

The ArcGIS project templates are a great starting point for developing your iOS applications. They include a number of project settings required for developing with the ArcGIS API for iOS.

To get started, first select ArcGIS from the list in the left pane, then select the appropriate ArcGIS project template and click the Choose... button.

Choosing an ArcGIS project template

Once you click Choose, you are ready to start developing your iOS application.

Each of the ArcGIS templates configure a number of settings within your Xcode project that you would have to otherwise set up yourself. You would need to manually configure these settings if you were to use one of XCode's default iOS project templates (see below for those details).

If you are just getting started, you may want to walk through the My First iPhone Application.

Using Apple's iOS Project Templates

If you do not wish to use the ArcGIS project templates, you can use one of the default iOS application project templates and then configure it to use the ArcGIS API. This may be necessary, for example, if you have already created an iOS application and wish to add ArcGIS capabilities to it. The following steps describe how to configure your project settings :

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 API package.

NoteNote:

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

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. 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.

NoteNote:

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.

4. 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 windo, 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/**

5. 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)

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.

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. It is automatically referenced by new projects created using the ArcGIS project templates, however you need to manually add it to existing projects or projects created using Apple's iOS templates. 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.

9/14/2011