El repositorio del SDK de Maps para iOS en GitHub contiene muestras que ilustran el uso del SDK de Maps para iOS en tu app para iOS. La app de ejemplo contiene código para destacar funciones del SDK y se puede usar como punto de partida para tu app.
Lista de muestras del SDK de Maps para iOS
A continuación, se incluyen algunos ejemplos de actividades clave de la app de demostración con sus respectivas reproducciones en las páginas vinculadas a modo de referencia rápida. Consulta la carpeta de muestras de GitHub para ver la lista completa de muestras disponibles.
La app de ejemplo del SDK de Maps para iOS está disponible como un archivo de descarga en GitHub.
Sigue estos pasos para instalar y probar la app de ejemplo del SDK de Maps para iOS.
Ejecuta git clone https://github.com/googlemaps-samples/maps-sdk-for-ios-samples.git para clonar el repositorio de muestras en un directorio local.
Abre una ventana de terminal, navega al directorio en el que clonaste los archivos de muestra y, luego, profundiza en el directorio GoogleMaps:
Swift
cd maps-sdk-for-ios-samples-main/GoogleMaps-Swift
pod installopen GoogleMapsSwiftDemos.xcworkspace
Objective-C
cd maps-sdk-for-ios-samples-main/GoogleMaps
pod installopen GoogleMapsDemos.xcworkspace
En Xcode, presiona el botón de compilación para compilar la app con el esquema actual. La compilación produce un error que te solicita que ingreses tu clave de API
en el archivo SDKConstants.swift para Swift o el archivoSDKDemoAPIKey.h
para Objective-C.
Edita el archivo SDKConstants.swift para Swift o el archivo SDKDemoAPIKey.h para Objective-C y pega tu clave de API en la definición de la constante apiKey o kAPIKey. Por ejemplo:
Swift
staticletapiKey="YOUR_API_KEY"
Objective-C
staticNSString*constkAPIKey=@"YOUR_API_KEY";
En el archivo SDKConstants.swift (Swift) o SDKDemoAPIKey.h (Objective-C), quita la siguiente línea, ya que se usa para registrar el problema definido por el usuario:
[null,null,["Última actualización: 2025-07-26 (UTC)"],[[["\u003cp\u003eThe Maps SDK for iOS provides a sample app with code examples showcasing key features, serving as a starting point for your iOS app development.\u003c/p\u003e\n"],["\u003cp\u003eYou can find a comprehensive list of samples in the GitHub repository and easily access specific feature implementations through provided links.\u003c/p\u003e\n"],["\u003cp\u003eTo run the full sample app locally, clone the repository, install dependencies using CocoaPods, and build the project in Xcode after configuring your API key.\u003c/p\u003e\n"],["\u003cp\u003eTroubleshooting steps are available if you encounter issues like not seeing a map after successfully running the app, guiding you to add your API key correctly.\u003c/p\u003e\n"]]],["The provided content focuses on using the Maps SDK for iOS. Key actions include cloning the sample app repository from GitHub, building the app in Xcode, and integrating an API key. The API key is obtained from the Google Cloud console. After entering the API key, you can build and run the project. You then can interact with the various features demonstrated, like displaying a basic map, adding markers, drawing shapes, enabling location, and handling events. Finally, the content mentions the necessity to grant the app location access.\n"],null,["Select platform: [Android](/maps/documentation/android-sdk/examples \"View this page for the Android platform docs.\") [iOS](/maps/documentation/ios-sdk/examples \"View this page for the iOS platform docs.\") [JavaScript](/maps/documentation/javascript/examples \"View this page for the JavaScript platform docs.\")\n\n\u003cbr /\u003e\n\nThe Maps SDK for iOS repository on\n[GitHub](https://github.com/googlemaps-samples/maps-sdk-for-ios-samples/tree/main/GoogleMaps)\ncontains samples illustrating the use of the Maps SDK for iOS\nin your iOS app. The sample app contains code for feature highlights of the SDK,\nand can be used starting point for your app.\n| **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](/maps/documentation/ios-sdk/get-api-key).\n\nMaps SDK for iOS samples list\n\nKey sample activities from the demo app are listed below and reproduced at the\nlinked pages for quick reference. See the GitHub [samples\nfolder](https://github.com/googlemaps-samples/maps-sdk-for-ios-samples/tree/main/GoogleMaps/GoogleMapsDemos/Samples)\nfor the full list of available samples.\n\n- [Display a basic map](/maps/documentation/ios-sdk/examples/basic-map)\n- [Display an info window for a marker](/maps/documentation/ios-sdk/examples/info-window-marker)\n- [Add a marker to a map](/maps/documentation/ios-sdk/examples/add-marker)\n- [Reverse geocode a location](/maps/documentation/ios-sdk/examples/reverse-geocode)\n- [Enable and disable map gestures](/maps/documentation/ios-sdk/examples/enable-disable-gestures)\n- [Handle marker events](/maps/documentation/ios-sdk/examples/handle-marker-events)\n- [Enable the My Location Button](/maps/documentation/ios-sdk/examples/enable-my-location)\n- [Draw polygons on a map](/maps/documentation/ios-sdk/examples/draw-polygons)\n- [Draw polylines on a map](/maps/documentation/ios-sdk/examples/draw-polylines)\n\nRun the full sample app locally\n\nThe Maps SDK for iOS sample app is available as a\n[download archive](https://github.com/googlemaps-samples/maps-sdk-for-ios-samples/archive/main.zip)\nfrom [GitHub](https://github.com/googlemaps-samples/maps-sdk-for-ios-samples/tree/main/GoogleMaps).\nFollow these steps to install and try the Maps SDK for iOS sample app.\n\n1. Run `git clone https://github.com/googlemaps-samples/maps-sdk-for-ios-samples.git` to clone the samples repository into a local directory.\n2. Open a terminal window, navigate to the directory where you cloned the sample files, and\n drill down into the GoogleMaps directory:\n\n Swift \n\n cd maps-sdk-for-ios-samples-main/GoogleMaps-Swift\n pod install\n open GoogleMapsSwiftDemos.xcworkspace\n\n Objective-C \n\n cd maps-sdk-for-ios-samples-main/GoogleMaps\n pod install\n open GoogleMapsDemos.xcworkspace\n\n3. In Xcode, press the compile button to [build the app](https://developer.apple.com/documentation/xcode/building-and-running-an-app) with the current scheme. The build produces an error, prompting you to enter your API key in the `SDKConstants.swift` file for Swift or`SDKDemoAPIKey.h` file for Objective-C.\n4. [Get an API key](/maps/documentation/ios-sdk/get-api-key) from your project with the [Maps SDK for iOS enabled](/maps/documentation/ios-sdk/cloud-setup#enabling-apis).\n5. Edit the `SDKConstants.swift` file for Swift or`SDKDemoAPIKey.h` file for Objective-C and paste your API key into the definition of either the `apiKey` or `kAPIKey` constant. For example: \n\n Swift \n\n ```swift\n static let apiKey = \"YOUR_API_KEY\"\n ```\n\n Objective-C \n\n ```objective-c\n static NSString *const kAPIKey = @\"YOUR_API_KEY\";\n ```\n6. In the `SDKConstants.swift` file (Swift) or`SDKDemoAPIKey.h` file (Objective-C), remove the following line, because it's used to register the user-defined issue: \n\n Swift \n\n ```swift\n #error (Register for API Key and insert here. Then delete this line.)\n ```\n\n Objective-C \n\n ```objective-c\n #error Register for API Key and insert here.\n ```\n7. Build and run the project. The iOS simulator window appears, showing a list of **Maps SDK Demos**.\n8. Choose one of the options displayed, to experiment with a feature of the Maps SDK for iOS.\n9. If prompted to allow GoogleMapsDemos to access your location, choose **Allow**."]]