react-native-maps: Expo SDK 51: AirGoogleMaps dir must be added to your xCode project to support GoogleMaps on iOS
Summary
After upgrading to Expo SDK 51, and using Expo Go, we receive the following error. We did not have this error with SDK 50.
Reproducible sample code
import MapView, { PROVIDER_GOOGLE } from 'react-native-maps'
<MapView
provider={PROVIDER_GOOGLE}
/>
Steps to reproduce
Start an Expo SDK 51 project, with the managed flow.
Run the app via Expo Go
Use provider google
Expected result
The map renders
Actual result
We get an error, saying a native dependency is missing. But since this is Expo managed, it should be fixed with them.
React Native Maps Version
1.14.0
What platforms are you seeing the problem on?
iOS (Google Maps)
React Native Version
0.74.1
What version of Expo are you using?
SDK 48
Device(s)
iPhone SE 3 (simulator), iPhone 14 Pro Max (device)
Additional information
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 9
- Comments: 45 (9 by maintainers)
Hi there! Google Maps is no longer supported in Expo Go for iOS. You can use Apple Maps in Expo Go instead (remove the prop
provider={PROVIDER_GOOGLE}from your<MapView />components) or switch to a development build (recommended). If you have already configured Google Maps for your production releases, no additional configuration will be necessary. Learn how to set up a development build.A few things to note about Expo Go:
I have a development build + Google Maps API key but I am still getting this error
@brentvatne why is nothing about this mentioned here: https://docs.expo.dev/versions/latest/sdk/map-view
@robinclaes - the decision was made because we are trying to reduce instances in Expo Go where behavior doesn’t immediately transfer over to a development build. in this case, you didn’t have to configure Google Maps to work in Expo Go because it used our Google API credentials, but when you create a development build or production build, it would no longer work and you would need to then create your own Google Maps credentials configure it. this is frustrating because it’s unexpected and at this point you’ll think you’ve already built support for maps, you may not have budgeted the time in for your release, or maybe you’ll just give up and go back to Expo Go. the state we’re moving towards is that, whenever possible, something that runs in Expo Go should run without changes in a development build.
I’m not sure I understand your comment 😃 Expo is much more than the “Expo Go” app - the sandbox app for experimenting and learning. I encourage you to take a look at development builds - which are like a version of Expo Go that you have full control over.
Ultimately, if you prefer to use other tooling, you should do what is best for you!
I also have a development build with API key and get the error
For anyone encountering this and uses Expo, I wrote a config plugin https://www.npmjs.com/package/react-native-maps-expo-plugin to do this without you having to manually tweak files:
Then add it to your app.json or app.config.js:
Now you can generate the native code and build:
What is CNG?
Why this is better than tweaking the generated native files yourself:
Here’s Expo documentation on why tweaking the files yourself is not a good idea: https://docs.expo.dev/workflow/overview/#what-if-i-want-to-edit-the.
In summary, the official react-native-maps installation requires manual modifications to native iOS files that get wiped out when using CNG (
npx expo prebuild --clean). This plugin automatically handles:In other words, it will do the
react-native-mapsinstallation instructions for you every time, so you can keep enjoying CNG!I also have a development build with API key and get the error
Once you run
npx expo prebuild, it will generate the folders for both Android and iOS then just follow this doc - https://github.com/react-native-maps/react-native-maps/blob/master/docs/installation.mdI’m also directly using development build, not Expo Go, but got hit with the same error. @WayneJWZLemon’s fix worked for me. To further add onto the description:
npx expo prebuildand adding the necessary lines mentioned in the guide, you could be prompted with the error'GoogleMaps/GoogleMaps.h' file not found. To fix this, go to your Podfile (in the .iOS folder created by prebuild) and addpod 'GoogleMaps'.and it should be added before the function call
use_native_modulesSo in my case, the code looks like
after adding the snippet.
This helped fixing the issue for me.
I agree with @jmejiamu—running Google Maps with react-native-maps in Expo command no longer works as expected. To resolve this, I ran:
Next, I opened ios/MyProject.xcworkspace in Xcode, navigated to the AppDelegate.mm file, and added my Google Maps API key following the instructions in the react-native-maps installation guide.
After launching the app from Xcode to the simulator, Google Maps rendered correctly.
@jmejiamu Thank you ! 🚀
Yeah because for me, I’m doing like a multi app setting, so I need 2 apps open at the same time. Just was easier that way, but meh, can simple just do a constants check if in
__DEV__to use not use google maps provider and just have production / dev builds use google.❤️
That’s crazy. Picture using development build on simulator on your laptop then expo go on your phone.
Lol this just made things way more complicated. Damn. Thanks for the update tho!
I have the same issue.
Default provider works fine on my apple device but renders Apple Maps
I have the same issue, is there any way to fix it?
Just read de docs and follow the steps.
My problem was that I used
npx expo prebuild --cleanand lost my previous config https://docs.expo.dev/versions/latest/sdk/map-view/@brentvatne thanks, anywhere where we can read up on the decision to remove this from Expo Go? Interested to know the Why.
I guess I have to switch to native because that was the only reason I used Expo… 😒
I’m facing the same issue. Version 50 worked perfectly… and iOS is forcing an update to version 51.