When I try to import react-native-google-mobile-ads, Expo gives multiple errors in my iOS build.
Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNGoogleMobileAdsModule' could not be found
Invariant Violation: "main" has not been registered.
I reconfigured my ios build and tried to change a few things in the ios folder but I kept getting the same error
I faced the same error, and managed to resolve the issue by following the below steps:
app.json
root > expo > extra
// old app.json
{
"expo": {
// ...
},
"react-native-google-mobile-ads": {
"android_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx",
"ios_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx"
}
}
// new app.json
{
"expo": {
// ...
"extra": {
"react-native-google-mobile-ads": {
"android_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx",
"ios_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx"
}
}
}
}
react-native-google-mobile-ads
libraryThe issue is resolved by version 14, "react-native-google-mobile-ads": "^14.0.0"
, which can be found here
Currently, both structures are required for a fully functional application that uses "react-native-google-mobile-ads". Issues have been open about this change and can be found here
// functional app.json
{
"expo": {
// ...
"extra": {
"react-native-google-mobile-ads": {
"android_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx",
"ios_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx"
}
}
},
"react-native-google-mobile-ads": {
"android_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx",
"ios_app_id": "ca-app-pub-xxxxxxxx~xxxxxxxx"
}
}