Skip to content

Google Maps Setup

This section covers the setup process for Google Maps SDK integration with MapConductor.

Use this provider when your app already depends on Google Maps SDK for iOS or needs Google map types through GoogleMapDesign.

  • iOS development environment (Xcode 15+)
  • Google Cloud Console account
  • Maps SDK for iOS enabled in your Google Cloud project
  • iOS deployment target set to 16.0 or higher
  1. Go to the Google Cloud Console
  2. Create a new project or select an existing one
  3. Enable the Maps SDK for iOS API
  4. Go to Credentials and create an API key
  5. Restrict the API key to your app’s bundle ID

Add the Google Maps SDK and MapConductor to your Xcode project:

  1. In Xcode, go to File > Add Packages
  2. Add the package:
    • https://github.com/MapConductor/ios-for-googlemaps

Call GMSServices.provideAPIKey(_:) once before any map view is displayed. The recommended place is your @main App struct:

import SwiftUI
import GoogleMaps
import MapConductorForGoogleMaps
@main
struct MyApp: App {
init() {
GMSServices.provideAPIKey("YOUR_GOOGLE_MAPS_API_KEY")
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}

Alternatively, pass the call via the sdkInitialize parameter on GoogleMapView:

GoogleMapView(
state: mapState,
sdkInitialize: { GMSServices.provideAPIKey("YOUR_GOOGLE_MAPS_API_KEY") }
) { ... }

If your app uses location services with Google Maps, add to Info.plist:

<key>NSLocationWhenInUseUsageDescription</key>
<string>We need your location to display on the map</string>

Build and run your app with the following code to verify the setup:

import SwiftUI
import MapConductorCore
import MapConductorForGoogleMaps
struct ContentView: View {
@StateObject var mapState = GoogleMapViewState(
cameraPosition: MapCameraPosition(
position: GeoPoint(latitude: 37.7749, longitude: -122.4194),
zoom: 12.0
)
)
var body: some View {
GoogleMapView(state: mapState)
.ignoresSafeArea()
}
}

If the map displays without errors, your setup is working. Test basic interactions (zoom, pan) to confirm everything is functioning correctly.

Map not displaying (gray screen)

  • Verify GMSServices.provideAPIKey(_:) is called before any map view is created
  • Check that Maps SDK for iOS is enabled in Google Cloud Console
  • Ensure the API key is not restricted to a different bundle ID
  • Verify iOS deployment target is 16.0 or higher

API key errors

  • Double-check the API key value passed to GMSServices.provideAPIKey(_:)
  • Verify the key has not been revoked
  • Check that Maps SDK for iOS is enabled in Google Cloud Console
  • Verify bundle ID restriction matches your app’s actual bundle ID

Build errors with CocoaPods conflicts

  • Ensure you’re using Swift Package Manager only (not mixing with CocoaPods)
  • Clean build folder (Cmd+Shift+K)
  • Delete derived data: ~/Library/Developer/Xcode/DerivedData
  • Rebuild project

If you need location-based features:

  1. Add location permissions to Info.plist (see step 4)
  2. Request user permission in your app:
import CoreLocation
class LocationManager: NSObject, CLLocationManagerDelegate {
let manager = CLLocationManager()
override init() {
super.init()
manager.delegate = self
manager.requestWhenInUseAuthorization()
}
}

Once Google Maps SDK is properly configured, you can use MapConductor’s GoogleMapView component as described in the Map View component documentation.

For more examples, see the Get Started tutorial.