You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`googleMapsApiKey`| iOS + Android | Shared fallback when platform-specific keys are omitted. |
184
-
|`iosGoogleMapsApiKey`| iOS | Injects `GoogleMapsIosApiKey` into `Info.plist`for `provider="google"`. |
184
+
|`iosGoogleMapsApiKey`| iOS | Injects `GoogleMapsIosApiKey` into `Info.plist`and sets `betterMaps.iosGoogleProvider` in `Podfile.properties.json` so the Google Maps SDK is linked.|
|`locationPermission`| iOS + Android | Foreground location message. Injects `NSLocationWhenInUseUsageDescription` plus `ACCESS_FINE_LOCATION` + `ACCESS_COARSE_LOCATION`. Pass `false` or omit to skip. |
187
187
|`locationAlwaysPermission`| iOS + Android | Background location message. Injects `NSLocationAlwaysAndWhenInUseUsageDescription` plus `ACCESS_BACKGROUND_LOCATION`; also supplies foreground usage strings and permissions when `locationPermission` is omitted. Pass `false` or omit to skip. |
@@ -398,7 +398,28 @@ The example app uses the config plugin. It reads `GOOGLE_MAPS_IOS_API_KEY` and `
398
398
399
399
### Bare React Native
400
400
401
-
- iOS: add a `GoogleMapsIosApiKey` string to `Info.plist`.
401
+
On iOS, `provider="google"` needs **two** host-app settings that the config plugin normally writes together:
402
+
403
+
1.**Runtime API key** — `GoogleMapsIosApiKey` in `Info.plist` (read when the map mounts).
404
+
2.**SDK linkage** — `"betterMaps.iosGoogleProvider": "true"` in `ios/Podfile.properties.json` (read by `react-native-better-maps.podspec` during `pod install` to add the `GoogleMaps` pod).
405
+
406
+
In a bare workflow the plugin does not run, so configure both manually:
407
+
408
+
```xml
409
+
<!-- Info.plist -->
410
+
<key>GoogleMapsIosApiKey</key>
411
+
<string>YOUR_API_KEY</string>
412
+
```
413
+
414
+
```json
415
+
// ios/Podfile.properties.json
416
+
{
417
+
"betterMaps.iosGoogleProvider": "true"
418
+
}
419
+
```
420
+
421
+
Then run `pod install` from `ios/`.
422
+
402
423
- Android: add `com.google.android.geo.API_KEY` metadata to `AndroidManifest.xml`.
403
424
404
425
### Google Map ID
@@ -538,6 +559,7 @@ See [example/.env.example](example/.env.example) for the supported environment v
| Map is blank when using Google Maps | Add a Google Maps API key through the Expo config plugin, `GoogleMapsIosApiKey` in `Info.plist`, or `com.google.android.geo.API_KEY` in `AndroidManifest.xml`. |
562
+
| iOS Google Maps key set but provider errors | iOS needs both `GoogleMapsIosApiKey` in `Info.plist`**and**`"betterMaps.iosGoogleProvider": "true"` in `Podfile.properties.json`, then `pod install`. The config plugin sets both; in bare workflow or with a stale `Podfile.properties.json`, they can drift apart. |
541
563
| New Architecture errors | Confirm React Native `0.78+`, New Architecture, and `react-native-nitro-modules` are installed, then rebuild the native app. |
542
564
| Provider throws before rendering | Check the [supported platforms](#supported-platforms) table. `openstreetmap` and `mapbox` are reserved for future support but do not render yet. |
543
565
| Expo Go does not load native maps | Use a development build after `expo prebuild`; native Nitro modules are not available in Expo Go. |
|`googleMapsApiKey`|`string`| — | Shared fallback for iOS and Android when platform-specific keys are omitted. |
45
-
|`iosGoogleMapsApiKey`|`string`| — | Injects `GoogleMapsIosApiKey` into `Info.plist`for `provider="google"` on iOS. |
45
+
|`iosGoogleMapsApiKey`|`string`| — | Injects `GoogleMapsIosApiKey` into `Info.plist`and sets `betterMaps.iosGoogleProvider` in `Podfile.properties.json` so the Google Maps SDK is linked on iOS.|
46
46
|`androidGoogleMapsApiKey`|`string`| — | Injects `com.google.android.geo.API_KEY` meta-data on Android. |
47
47
|`locationPermission`|`string \| false`| — | Foreground location message. Injects iOS `NSLocationWhenInUseUsageDescription` plus Android `ACCESS_FINE_LOCATION` and `ACCESS_COARSE_LOCATION`. |
48
48
|`locationAlwaysPermission`|`string \| false`| — | Background location message. Injects iOS `NSLocationAlwaysAndWhenInUseUsageDescription` plus Android `ACCESS_BACKGROUND_LOCATION`; also supplies foreground usage strings and permissions when `locationPermission` is omitted. |
@@ -86,7 +86,9 @@ expo prebuild --clean
86
86
The plugin injects:
87
87
88
88
-**Android:**`com.google.android.geo.API_KEY` meta-data (when `googleMapsApiKey` or `androidGoogleMapsApiKey` is set) and location permissions (when location options are set)
89
-
-**iOS:**`GoogleMapsIosApiKey` (when `googleMapsApiKey` or `iosGoogleMapsApiKey` is set) and location usage description strings (when location options are set)
89
+
-**iOS:**`GoogleMapsIosApiKey` in `Info.plist` and `betterMaps.iosGoogleProvider` in `Podfile.properties.json` (when `googleMapsApiKey` or `iosGoogleMapsApiKey` is set), plus location usage description strings (when location options are set)
90
+
91
+
On iOS, the API key and pod linkage are separate artifacts. The plugin keeps them in sync during prebuild. If you later remove Google Maps keys from the plugin config, re-run `expo prebuild` so `Podfile.properties.json` is updated and run `pod install` — a stale `"betterMaps.iosGoogleProvider": "true"` can leave the SDK linked after you stop providing a key. Bare React Native apps without the plugin must set both manually; see [Bare React Native](../README.md#bare-react-native) in the README.
90
92
91
93
## Run
92
94
@@ -111,6 +113,7 @@ The example's `prebuild` script builds the plugin (`build:plugin`) before runnin
| Blank Google map | Ensure `googleMapsApiKey` or the platform-specific Google Maps key is set, then run `expo prebuild` again. |
116
+
| iOS Google Maps key present but provider fails | iOS needs `GoogleMapsIosApiKey` in `Info.plist`**and**`"betterMaps.iosGoogleProvider": "true"` in `Podfile.properties.json`, then `pod install`. Re-run prebuild after changing plugin keys so both stay aligned. |
114
117
| Location dot not showing | Set `locationPermission` or `locationAlwaysPermission` in the plugin options and re-run prebuild. |
115
118
| Plugin not found | Confirm `react-native-better-maps` is installed and listed in `plugins`. |
116
119
|`Cannot find module './plugin/build/index'`| Run `bun run build:plugin` in the package (or `bun run build` from the repo root) before prebuild when using a workspace link. |
Copy file name to clipboardExpand all lines: package/ios/GoogleMapsAPIKey.swift
+6Lines changed: 6 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,6 @@
1
1
import Foundation
2
+
3
+
#if canImport(GoogleMaps)
2
4
import GoogleMaps
3
5
4
6
enumGoogleMapsAPIKey{
@@ -20,15 +22,19 @@ enum GoogleMapsAPIKey {
20
22
configuredKey = key
21
23
}
22
24
}
25
+
#endif
23
26
24
27
enumMapProviderConfigurationError:LocalizedError{
25
28
case missingGoogleMapsIosApiKey
29
+
case googleMapsSdkNotLinked
26
30
case unsupportedIOSProvider(MapProvider)
27
31
28
32
varerrorDescription:String?{
29
33
switchself{
30
34
case.missingGoogleMapsIosApiKey:
31
35
return"react-native-better-maps: provider=\"google\" on iOS requires GoogleMapsIosApiKey in the host app Info.plist."
36
+
case.googleMapsSdkNotLinked:
37
+
return"react-native-better-maps: provider=\"google\" on iOS requires iosGoogleMapsApiKey or googleMapsApiKey in the react-native-better-maps config plugin to link the Google Maps SDK, then run pod install."
32
38
caselet.unsupportedIOSProvider(provider):
33
39
return"Map provider \"\(provider)\" is not supported on iOS."
0 commit comments