Using the Samples

A number of samples are provided for the ArcGIS Runtime SDK for iOS. These samples highlight some of the functionality available in the API and common patterns and practices for using the API. The samples can help you jump start your application development.

Samples installed on disk

When you install the ArcGIS Runtime SDK for iOS SDK, a single sample, MapViewDemo, is also installed on disk. This sample is located at ${HOME}/Library/SDKs/ArcGIS/Samples/MapViewDemo . The sample is provided as an XCode project that you can open by simply double-clicking the .xcodeprojfile. Once open, you can quickly run the sample from within XCode by clicking on the Build and Run button in the toolbar

Build and Run Too
Build and Run tool

The sample illustrates how you can create a basic application containing a map view, a tiled map service layer, and a dynamic map service layer.

By running the sample, you can also easily verify that the SDK was correctly installed on your machine, and that your system satisfies the prerequisites for using the API.

Samples on arcgis.com

Many more samples are available on www.arcgis.com under the ArcGIS for iOS Developer Samples group . The samples are provided as zip files containing entire XCode projects. You will need to download the zip file, unpack it, and double-click the .xcodeproj file to open the sample in XCode. From there you can easily build and run the sample as before.

Be sure to check the group regularly for updates and new additions. You can also send us feedback and ideas about which samples you would like to see at iOSDevTeam@esri.com.

Troubleshooting problems

There may be times when the samples don't build or run properly right from the outset. Here are some tips that could help you troubleshoot the problems.

Base SDK

As mentioned previously, each sample is provided as an entire XCode project including the source code, graphics, and XCode-specific project files. The project files store many common build settings such as the frameworks and libraries to link to, the SDK to use, the targets to build, and so on.

Most commonly when a sample doesn't build properly, it's probably because the project is trying to reference an iOS SDK that is not available on your machine. This might happen, for instance, if you installed a more recent version of the iOS SDK than what was used to create the sample. In such cases, the Overview Toolbar menu in XCode will display a Base SDK Missing warning.

Base SDK Missing
Base SDK Missing warning

To fix the problem, you need update the Base SDK setting. You can choosing the Edit Active Target option under the Project menu. This will bring up the Info window. Then, under the Build tab, update the Base SDK setting by choosing an iOS SDK that is installed on your machine.

One thing to consider before making any changes to a Target, is to make sure you are modifying the correct configuration. Every target has 2 configurations by default - Release and Debug. These configurations are used to build the Release and Debug versions of your application respectively. Many settings, such as the Base SDK, typically remain the same for both configurations. When you modify such settings, remember to modify the settings for each configuration. You can do this by either modifying each configuration separately, or by modifying both configurations simultaneously by selecting the All Configurations option.

All Configurations
Edit All Configurations simultaneously

Device v/s Simulator

Another common reason why a sample may not build properly is if the project is configured to run on a device. In such cases, you may encounter an error as shown below -

Code Sign Error
Code Sign error when building sample for device

The simplest way to avoid this error is to run the sample on the simulator. You can do this by choosing the Simulator option in the Overview toolbar menu.

Simulator option
Run on Simulator

If you really do want to run on a device, you will need to do a few things -

1. You will need to obtain a valid Development Certificate from Apple if you don't have one already. This certificate needs to be installed on your development machine. You can find more information about Obtaining your iOS Development Certificate from the iOS Provisioning Portal. (Note, you will need to sign in with your Apple ID)

2. You will also need to create a Development Provisioning Profile from the iOS Provisioning Portal and install it on your development machine and each iOS device you intend to use. A provisioning profile is used to authorize an application (specified by an App ID) created by a developer (specified by a developer certificate) to run on a device (specified by a device ID). You can find more information about this process in the Managing Devices and Digital Identities section of the iOS Development Guide and also in the iOS Developer Program User Guide (Note, you will need to sign in with your Apple ID).

You will also need to make the following changes to the project -

3. You will need to modify the sample's App ID. Under the Project menu, choose the the Edit Active Target option . This will bring up the Info window. Then under the Properties tab, modify Identifier property by replacing "com.yourcompany" with the App ID used in your provisioning profile.

Sample App ID
Sample App ID

4.You will need to digitally sign the application. Under the Project menu, choose the the Edit Active Target option . This will bring up the Info window. Then, under the Build tab, scroll down to the Code Signing Identify section, and choose your provisioning profile to digitally sign the application.

Code Signing Identity
Select a Code Signing Identity

Apple's Technical Note TN2250 has more information about the Code Signing process.

Once you've completed these steps, ensure your device is connected to your development machine, then build and run the project. The sample application should get installed on your device and then launch automatically.

5/9/2012