ios - Expo 应用程序因react-native-google-mobile-ads 崩溃 [app.json 中的 react-native-google-mobile-ads 键中未找到 ios_appd_id 键]

标签 ios react-native expo admob eas

我在使用react-native-google-mobile-ads时遇到此错误:https://github.com/invertase/react-native-google-mobile-ads/issues/194

我的应用程序正在使用带有 EAS 构建系统的 expo 管理工作流程。

我的应用程序针对 Android 构建,但在 iOS 上失败,并出现以下错误:在 app.json 的 React-native-google-mobile-ads 键中找不到 ios_appd_id 键。如果没有它,应用程序将会崩溃。 这很奇怪,因为 by app.json 有正确的定义:

"react-native-google-mobile-ads": {
    "android_app_id": "ca-app-pub-xxx",
    "ios_app_id": "ca-app-pub-xxx",
    "user_tracking_usage_description": "This identifier will be used to deliver personalized ads to you."
  }

无论我如何更改代码或依赖项,这种情况都会不断出现。为了调试并找到可重现的示例,我慢慢构建了一个新项目,该项目是通过 expo init 创建的(就像我最初的项目一样)。然而,我现在已经将每个文件精确地复制到新的、全新的应用程序中,包括所有 Assets (图标、启动画面),并且我根本无法重现该错误。这两个应用程序是彼此的精确复制品(code、app.json、eas.json、package.json)。事实上,新的应用程序工作得非常好,并且在开发和生产模式下的行为都符合预期。我很困惑。上述错误发生在构建过程的“运行 faSTLane”阶段。

有错误的 faSTLane 日志在这里:https://pastebin.com/4cD8T3Sn 新应用程序的日志完全相同,只是日志的最后几行是成功消息:

› Copying   ios/googleadmobtest/Supporting/Expo.plist ➜ ./Expo.plist
› Compiling googleadmobtest » SplashScreen.storyboard
› Preparing googleadmobtest » Info.plist
› Executing googleadmobtest » Bundle React Native code and images
› Generating debug googleadmobtest » googleadmobtest.app.dSYM
› Executing googleadmobtest » [CP] Copy Pods Resources
› Executing googleadmobtest » [CP-User] [RNGoogleMobileAds] Configuration
› Signing   googleadmobtest » googleadmobtest.app
› Creating  googleadmobtest » googleadmobtest.app
› Archive Succeeded
Generated plist file with the following values:
▸ -----------------------------------------
▸ {
▸   "method": "ad-hoc",
▸   "provisioningProfiles": {
▸     "com.arham23.googleadmobtest": "c88fe3cb-0ed2-427d-ae68-ec6a484dccca"
▸   },
▸   "signingStyle": "manual"
▸ }
▸ -----------------------------------------
$ /usr/bin/xcrun /usr/local/lib/ruby/gems/2.7.0/gems/fastlane-2.205.2/gym/lib/assets/wrap_xcodebuild/xcbuild-safe.sh -exportArchive -exportOptionsPlist '/var/folders/h2/gp9wlkv11lg0qj6y2mnqgc_40000gn/T/gym_config20220815-4163-q9vcsf.plist' -archivePath /Users/expo/Library/Developer/Xcode/Archives/2022-08-15/googleadmobtest\ 2022-08-15\ 23.44.51.xcarchive -exportPath '/var/folders/h2/gp9wlkv11lg0qj6y2mnqgc_40000gn/T/gym_output20220815-4163-1ishkbk' OTHER_CODE_SIGN_FLAGS="--keychain /var/folders/h2/gp9wlkv11lg0qj6y2mnqgc_40000gn/T/turtle-v2-9ac5a45d-33ef-4193-bf51-33b05b2e1e98.keychain"
Compressing 1 dSYM(s)
$ cd '/Users/expo/Library/Developer/Xcode/Archives/2022-08-15/googleadmobtest 2022-08-15 23.44.51.xcarchive/dSYMs' && zip -r '/Users/expo/workingdir/build/ios/build/googleadmobtest.app.dSYM.zip' *.dSYM
▸   adding: googleadmobtest.app.dSYM/ (stored 0%)
▸   adding: googleadmobtest.app.dSYM/Contents/ (stored 0%)
▸   adding: googleadmobtest.app.dSYM/Contents/Resources/ (stored 0%)
▸   adding: googleadmobtest.app.dSYM/Contents/Resources/DWARF/ (stored 0%)
▸   adding: googleadmobtest.app.dSYM/Contents/Resources/DWARF/googleadmobtest (deflated 75%)
▸   adding: googleadmobtest.app.dSYM/Contents/Info.plist (deflated 44%)
Successfully exported and compressed dSYM file
Successfully exported and signed the ipa file:
/Users/expo/workingdir/build/ios/build/googleadmobtest.ipa

我可以提供任何其他必要的信息,我对博览会和 react native 有点陌生,所以我不确定什么是相关的。我原来的应用程序的配置似乎有问题,但我不知道问题是什么。我想尝试删除所有 ios pod 并重新安装,但该应用程序由 expo 管理,我不确定如何在 expo CLI 中完成此操作。任何帮助将不胜感激。

最佳答案

为了解决此错误,我将配置拆分为两个文件。世博会默认加载app.config.json超过app.jsonreact-native-google-mobile-adsapp.json

app.json

{ 
    "react-native-google-mobile-ads": {
        ...app ids
    }
}

app.config.json

{
    "expo": {
        "name": ...
        ...
    }
}

关于ios - Expo 应用程序因react-native-google-mobile-ads 崩溃 [app.json 中的 react-native-google-mobile-ads 键中未找到 ios_appd_id 键],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73370621/

相关文章:

ios - 通过完成 block 传递的函数有时不运行...如何调试

ios - 没有标签的 SwiftUI Picker View

docker - 您能否在具有苹果 2 因素身份验证的 CI 环境中使用 "expo build:ios"以及如何使用

ios - 在 React Native Firebase ios 中找不到 Absl/numeric/int128_have_intrinsic.inc' 文件

javascript - 在 React Native 的 TabNavigator 中再次按下时滚动到当前选项卡的顶部

javascript - react native : there is way to use axios. 把?

android - expo-auth-session - 返回应用程序时的两个应用程序选项

ios - 设置最小日期时忽略 UIDatePicker 日期

ios - iOS 应用的最大尺寸

reactjs - 无法从 AssyncStorage 检索数据