排毒:在 Info.plist 中找不到字段 CFBundleIdentifier

Posted

技术标签:

【中文标题】排毒:在 Info.plist 中找不到字段 CFBundleIdentifier【英文标题】:Detox: field CFBundleIdentifier not found inside Info.plist 【发布时间】:2021-03-12 05:54:06 【问题描述】:

我有一个 ReactNative 0.63.2 项目。它运行在模拟器上,它运行在物理设备上。决定现在就开始使用 Detox。

在运行示例测试时,我遇到了这个错误:

Error: field CFBundleIdentifier not found inside Info.plist of app binary at /Users/jesus/Documents/projects/appname/ios/build/Build/Products/Debug-iphonesimulator/Appname.app

在我的Info.plist

<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>

我的.detoxrc.json


  "testRunner": "jest",
  "runnerConfig": "e2e/config.json",
  "configurations": 
    "ios": 
      "type": "ios.simulator",
      "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/Appname.app",
      "build": "xcodebuild -project ios/Appname.xcodeproj -scheme Appname -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
      "device": 
        "type": "iPhone 11"
      
    ,
    "android": 
      "type": "android.emulator",
      "binaryPath": "android/app/build/outputs/apk/debug/app-debug.apk",
      "build": "cd android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && cd ..",
      "device": 
        "avdName": "Pixel_API_28_AOSP"
      
    
  

我检查了 Xcode > General 中是否设置了 Bundle Identifier。在 Build Settings > Packaging 下还有一个字段,其中 app.appname 设置正确。

【问题讨论】:

【参考方案1】:

这与排毒无关。

检查 .app 包中的 Info.plist(而不是源代码中的 Info.plist)。最有可能的是,您的捆绑包已损坏。 iOS 要求每个应用程序都有一个有效的包标识符。 PRODUCT_BUNDLE_IDENTIFIER 可能未在 Xcode 构建设置中正确定义。

【讨论】:

感谢您对此进行调查!我发现该应用程序实际上位于与我预期不同的目录中。

以上是关于排毒:在 Info.plist 中找不到字段 CFBundleIdentifier的主要内容,如果未能解决你的问题,请参考以下文章

在 Info.plist 中找不到捆绑显示名称

在路径 build/Debug-iphonesimulator/XXX.app/Info.plist 中找不到目标应用程序的 Info.plist

在 Info.plist CFBundleSupportedPlatforms 或 modplug 的 Mach-O LC_VERSION_MIN 中找不到平台系列

在我的 XCode 项目中找不到 Cordova.plist

如果在 cfbundlelocalizations 中找不到语言键,如何设置默认语言

Xcode 找不到本地化的 info.plist