The SDK demo apps supplied with the Places SDK for iOS demonstrate a number of features including place autocomplete, and place photos. In addition, you can find code snippets on each page of this developer's guide.
Try the SDK demos using CocoaPods
The Places SDK for iOS is available as a CocoaPods pod. CocoaPods is an open source dependency manager for Swift and Objective-C Cocoa projects.
The Places SDK for iOS supplies a set of SDK demo apps that you can
install and run using the
pod try command:
Follow these steps to install CocoaPods and try the Places 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
pod try GooglePlacescommand. CocoaPods updates your spec repositories, then opens the SDK demos in a temporary Xcode project,
- Enable the Places SDK for iOS for your Google Cloud Platform Console project.
- If you don't yet have an API key, follow the
instructions to set up
a project on the Google Cloud Platform Console and get an API key. When configuring the
key on the Google Cloud Platform 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
SDKDemoAPIKeyfile and paste your API key into the appropriate constant. For example:
internal let kPlacesAPIKey = "YOUR_API_KEY"
- If Xcode prompts you to unlock the
SDKDemoAPIKeyfile for editing, choose Unlock.
- If present, remove the following line, because it's used to register the
#error Register your API key and insert here, then delete this line.
- Build and run the project again.
- If the build fails or the app crashes with an error about your API key
when you first run it, double check to make sure that you have provided the
keys required in the
- If you are running the GooglePlaces demos, the iOS simulator window will show a list of Places Demos.
- If prompted to allow GooglePlacesDemos to access your location, choose Allow.
- The sample you chose is now ready to run.
Use code snippets from the developer's guide
Each page in the developer's guide includes code snippets illustrating a particular feature of the API. For example, see the guides for autocomplete, get current place, photos, and other pages in this guide.