Google Maps setup
How to drive the Google Maps SDK for iOS through MapConductor. Pick this provider when your app already depends on Google Maps, or when you need the map types on GoogleMapDesign.
Before you start
Get an API key
- Open the Google Cloud Console.
- Create a project or select an existing one.
- Enable the Maps SDK for iOS API.
- Create an API key under Credentials.
- Restrict the key to your app's bundle ID.
Add it with Swift Package Manager
Use File > Add Package Dependencies in Xcode and paste the package URL. The native SDK comes in as a transitive dependency — you do not add it separately.
https://github.com/MapConductor/ios-for-googlemaps
dependencies: [
.package(url: "https://github.com/MapConductor/ios-sdk-core", from: "1.1.4"),
.package(url: "https://github.com/MapConductor/ios-for-googlemaps", from: "1.0.0"),
],
targets: [
.target(
name: "YourApp",
dependencies: [
.product(name: "MapConductorCore", package: "ios-sdk-core"),
.product(name: "MapConductorForGoogleMaps", package: "ios-for-googlemaps"),
]
),
]Initialise the SDK
Call GMSServices.provideAPIKey(_:) exactly once, before any map view is created. The @main App struct is the recommended place.
import SwiftUI
import GoogleMaps
import MapConductorForGoogleMaps
@main
struct MyApp: App {
init() {
GMSServices.provideAPIKey("YOUR_GOOGLE_MAPS_API_KEY")
}
var body: some Scene {
WindowGroup {
ContentView()
}
}
}// Alternative: call it from the view's sdkInitialize closure
GoogleMapView(state: mapState, sdkInitialize: {
GMSServices.provideAPIKey("YOUR_GOOGLE_MAPS_API_KEY")
})Add the location permission (if needed)
If you use location services with Google Maps, declare the purpose in Info.plist and request permission from the app.
<key>NSLocationWhenInUseUsageDescription</key> <string>We need your location to display on the map</string>
import CoreLocation
final class LocationManager: NSObject, ObservableObject, CLLocationManagerDelegate {
private let manager = CLLocationManager()
override init() {
super.init()
manager.delegate = self
}
func requestPermission() {
manager.requestWhenInUseAuthorization()
}
}VERIFY
What you should see
Build and run this ContentView. If the map renders and zoom and pan work, you are done.
import SwiftUI
import MapConductorCore
import MapConductorForGoogleMaps
struct ContentView: View {
@StateObject var mapState = GoogleMapViewState(
cameraPosition: MapCameraPosition(
position: GeoPoint(latitude: 35.6762, longitude: 139.6503),
zoom: 12.0
)
)
var body: some View {
GoogleMapView(state: mapState)
.ignoresSafeArea()
}
}Map designs
GoogleMapDesign maps onto Google's map types.
Troubleshooting
The map does not appear (grey screen)
- Confirm GMSServices.provideAPIKey(_:) runs before any map view is created.
- Check Maps SDK for iOS is enabled in the Console.
- Verify the key's bundle ID restriction matches your actual bundle ID.
- Check the deployment target is iOS 16.0 or later.
The build fails
- Clean the build folder (Cmd+Shift+K).
- Delete ~/Library/Developer/Xcode/DerivedData and rebuild.
- Refresh the Swift Package Manager dependencies, and avoid mixing in CocoaPods.
Next
Once GoogleMapView renders, markers, polylines and circles use the shared API — swapping providers does not rewrite them.