react-native-google-mobile-ads 在 expo ios 构建上出现错误

问题描述 投票:0回答:1

当我尝试导入react-native-google-mobile-ads时,Expo在我的iOS构建中给出了多个错误。

Invariant Violation: TurboModuleRegistry.getEnforcing(...): 'RNGoogleMobileAdsModule' could not be found

Invariant Violation: "main" has not been registered.

我重新配置了我的 ios 版本并尝试更改 ios 文件夹中的一些内容,但我不断收到相同的错误

react-native expo admob
1个回答
0
投票

首先,我从 expo 组件中删除了 app.config.js 文件中的 react-native-google-mobile-ads 组件,并将其更改如下:

'react-native-google-mobile-ads': {
ios_app_id: 'ca-app-pub-xxxxxxxxxxxxxxxxxxxxxxxxxx~yyyyyyyyyyyy',
android_app_id: 'ca-app-pub-xxxxxxxxxxxxxxxxxxxxxxxxxx~yyyyyyyyyyyy',
},

然后我将以下内容添加到ios文件夹中的Info.plist文件中:

<key>GADApplicationIdentifier</key>
<string>ca-app-pub-xxxxxxxxxxxxxxxxxxxxxxxx~yyyyyyyyyyyyyy</string>

然后我将以下内容添加到 AppDelegate.m 文件(也在 ios 文件夹中):

#import <GoogleMobileAds/GoogleMobileAds.h>

最后,我在终端中运行了以下命令:

cd ios
rm -rf Pods
rm -rf Podfile.lock
pod install
cd..
expo run:ios
© www.soinside.com 2019 - 2024. All rights reserved.