Document Location SDK for iOS Guides Set Up Your Project Set Up with CocoaPods

Set Up with CocoaPods

Automatic deployment saves you the time of manually configuring your project, helping you build your application more efficiently. The automatic deployment setup process is described in detail in the Getting Started Guide. This page highlights important notes and considerations.

Install CocoaPods

Step 1: Upgrade Gem

An outdated gem version may cause installation or upgrade failures. Upgrade gem using the following command:

sudo gem update --system

Step 2: Install CocoaPods

Check your OS X version.

If your OS X version is 10.11 or earlier, run the following commands to install CocoaPods:

sudo gem install cocoapods
pod setup

If your OS X version is later than 10.11, run the following commands:

sudo gem install -n /usr/local/bin cocoapods
pod setup

Note: The installation process may take a long time and can fail due to network conditions. You may need to try multiple times until it succeeds.

Install the SDK Using CocoaPods

Step 1: Create a Podfile

Create a file named Podfile in the same directory as your project's .xcodeproj file. If you haven't created an Xcode project yet, create one and save it to your local computer. The Podfile content is shown below (using the 3D Map SDK as an example; refer to the table below for other SDK pod names):

platform :ios, '7.0' # System version
target 'YourProjectTarget' do # Project name
     pod 'AMap3DMap'  # 3D Map SDK
end

Podfile configuration with the AMapLocation pod entry for an iOS Location SDK project

AMAP iOS SDK Pod Names

SDK

IDFA Version

No-IDFA Version

Notes

3D Map SDK

AMap3DMap

AMap3DMap-NO-IDFA

3D Map and 2D Map cannot be used simultaneously

Search SDK

AMapSearch

AMapSearch-NO-IDFA

-

Location SDK

AMapLocation

AMapLocation-NO-IDFA

-

Navigation SDK

AMapNavi

AMapNavi-NO-IDFA

Includes the 3D Map SDK; no need to import it separately

Step 2: Configure and Install the SDK

Run the following commands to configure and install the SDK:

pod repo update  # Ensures the local map-related SDK is up to date
pod install

Note: The pod 'AMapLocation' command also imports the Foundation SDK, which may affect App Store submission. Click here to learn more about the Foundation SDK.

Step 3: Open the Project

After the command executes successfully, a .xcworkspace file is generated. Open the .xcworkspace file to launch your project (do not open the .xcodeproj file at the same time), as shown below.

Finder showing the .xcworkspace file generated after running pod install for an iOS AMAP Location SDK project

Upgrade the SDK

If you have already installed the AMAP iOS Map SDK and want to update to the latest version, run the following commands in the directory containing your Podfile:

pod repo update # Ensures the local map-related SDK is up to date
pod update

Note: The pod update command also updates the Foundation SDK, which may affect App Store submission. Click here to learn more about the Foundation SDK.

Specify an SDK Version

To use a specific version of the SDK, modify your Podfile to include the version number. For example:

platform :ios, '7.0' # System version
target 'YourProjectTarget' do  # Project name
   pod 'AMap3DMap', '~>4.4.1' # Specify the version number here
end

Then run the following command:

pod repo update # Ensures the local map-related SDK is up to date
pod install