The SDK demo app supplied with the Google Maps SDK for iOS includes samples for the feature highlights of the SDK. In addition, you can find code snippets on each page of this developer's guide.
Try the SDK demos using CocoaPods
The Google Maps SDK for iOS is available as a CocoaPods pod. CocoaPods is an open source dependency manager for Swift and Objective-C Cocoa projects.
The Google Maps SDK for iOS supplies an SDK demo app that you can
install and run using the
pod try GoogleMaps command. Follow
these steps to install CocoaPods and try the Google Maps SDK for iOS.
- If you don't already have the CocoaPods tool, install it on macOS by
running the following command from the terminal. For details, see the CocoaPods
Getting Started guide.
sudo gem install cocoapods
- Open a terminal window and run the following command:
pod try GoogleMaps
CocoaPods updates your spec repositories, then opens the SDK demos in a temporary Xcode project,
- In Xcode, press the compile button to build and then run the current
scheme. The build produces an error, prompting you to enter your API key
- If you don't yet have an API key, follow the
instructions to set up
a project on the Google API Console and get an API key. When configuring the
key on the Google API Console, you can specify your app's bundle identifier to
ensure that only your app can use the key. The default bundle identifier of
the SDK samples app is
- Edit the
SDKDemoAPIKey.hfile and paste your API key into the definition of the
kAPIKeyconstant. For example:
static NSString *const kAPIKey = @"YOUR_API_KEY";
- If Xcode prompts you to unlock the
SDKDemoAPIKey.hfile for editing, choose Unlock.
- Remove the following line, because it's used to register the user-defined
#error Register for API Key and insert here.
- Build and run the project. The iOS simulator window appears, showing a list of Maps SDK Demos.
- Choose one of the options displayed, to experiment with a feature of the Google Maps SDK for iOS.
- If prompted to allow GoogleMapsDemos to access your location, choose Allow.