Select platform: [Android](https://developers.google.com/maps/documentation/places/android-sdk/examples.md.txt "View this page for the Android platform docs.") [iOS](https://developers.google.com/maps/documentation/places/ios-sdk/examples.md.txt "View this page for the iOS platform docs.") [JavaScript](https://developers.google.com/maps/documentation/javascript/examples.md.txt "View this page for the JavaScript platform docs.")

The Places SDK for iOS demo app on
[GitHub](https://github.com/googlemaps-samples/ios-places-sdk-samples)
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.
Import and build the
app, add your API key, view the demo, and use the sample code supplied as a
starting point for your app.

When you run the sample app, it displays a list of available samples that you can
run on your own device. Select one of the options.

> [!NOTE]
> **Troubleshooting:** If the sample app runs successfully but you don't see a map, check that you've added your API key to the app's manifest file, as described in [Using API Keys](https://developers.google.com/maps/documentation/places/ios-sdk/get-api-key.md.txt).

## Run the full sample app locally

The Places SDK for iOS sample app is available as a
[download archive](https://github.com/googlemaps-samples/ios-places-sdk-samples/archive/main.zip)
from [GitHub](https://github.com/googlemaps-samples/ios-places-sdk-samples)
Follow these steps to install and try the Places SDK for iOS sample app.

1. [Download
   the code sample archive](https://github.com/googlemaps-samples/ios-places-sdk-samples/archive/main.zip) from [GitHub](https://github.com/googlemaps-samples/ios-places-sdk-samples) and unpack the archive. Alternatively, clone the repository into a local directory:

   ```
   git clone https://github.com/googlemaps-samples/ios-places-sdk-samples.git
   ```
2. Open a terminal window, navigate to the directory where you expanded the sample files, and
   drill down into the directory for the version you want to use:

   ### SwiftUI

       cd ios-places-sdk-samples/GooglePlacesDemos/
       open GooglePlacesDemos.xcodeproj

   ### Swift

       cd ios-places-sdk-samples/GooglePlaces-Swift/
       open GooglePlacesSwiftDemos.xcodeproj

   ### Objective-C

       cd ios-places-sdk-samples/Archive/GooglePlaces
       open GooglePlacesXCFrameworkDemos.xcodeproj

3. In the Xcode project, go to **File** \> **Add Package Dependencies** . Enter <https://github.com/googlemaps/ios-places-sdk> as the URL, press **Enter** to pull in the package, and click **Add Package**.
4. Enable the [Places SDK for iOS](https://console.cloud.google.com/flows/enableapi?apiid=placesios&keyType=CLIENT_SIDE_IOS&reusekey=true) for your Google Cloud console project.
5. [Get an API key](https://developers.google.com/maps/documentation/places/ios-sdk/get-api-key.md.txt) from your project with the [Places API and/or Places API (New) enabled](https://developers.google.com/maps/documentation/places/ios-sdk/cloud-setup#enabling-apis).
6. Add your API key to the app using the appropriate instructions below.

   ### SwiftUI

   Create a local configuration file called `GooglePlacesDemos.xcconfig` for your API key,
   in the same directory as the demo application's `Info.plist` file (GooglePlacesDemos/GooglePlacesDemos).


   Add a line to your config file to define your API key:


   `PLACES_API_KEY = YOUR_PLACES_API_KEY`

   Substitute `YOUR_PLACES_API_KEY` with the API key from the previous steps.

   See [Configuration Settings File (xcconfig) format](https://help.apple.com/xcode/mac/11.4/#/dev745c5c974) for help on creating a local configuration file.

   ### Swift

   Edit the `SDKDemoAPIKey` file and paste your API key
   into the appropriate constant. For example:

   ```swift
   let placesAPIKey = "YOUR_API_KEY"
   ```

   If present, remove the following line:

   ```swift
   #error (Register for API Key and insert here. Then delete this line.)
   ```

   If Xcode prompts you to unlock the `SDKDemoAPIKey` file for
   editing, choose **Unlock**.

   ### Objective-C

   Edit the `SDKDemoAPIKey` file and paste your API key
   into the appropriate constant. For example:

   ```objective-c
   static NSString *const kAPIKey = @"YOUR_API_KEY";
   ```

   If present, remove the following line

   ```objective-c
   #error (Register for API Key and insert here. Then delete this line.)
   ```

   If Xcode prompts you to unlock the `SDKDemoAPIKey` file for
   editing, choose **Unlock**.
7. [Build the app](https://developer.apple.com/documentation/xcode/building-and-running-an-app).
8. If the build fails or the app crashes with an error about your API key when you first run it, make sure that you have provided the keys required in the instructions above.
9. If you run the sample app, the iOS simulator window will show a list of Places Demos.
10. If prompted to allow the demo app to access your location, choose **Allow**.
11. The sample you chose is now ready to run.