'Detox: field CFBundleIdentifier not found inside Info.plist

I've got a ReactNative 0.63.2 project. It runs on the simulator, it runs on the physical device. Decided to get started with Detox now.

When running the sample test, I run into this error:

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

In my Info.plist:

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

My .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"
      }
    }
  }
}

I checked that there is a Bundle Identifier set in Xcode > General. There is also a field under Build Settings > Packaging which has app.appname set properly.



Solution 1:[1]

This is unrelated issue to Detox.

Check the Info.plist inside your .app bundle (not the Info.plist in your source code). Most likely, your bundle is broken. iOS requires a valid bundle identifier for every app. The PRODUCT_BUNDLE_IDENTIFIER might not be correctly defined inside your Xcode build settings.

Solution 2:[2]

I had the same problem.

I had problems building and solved them by copy pasting the command that react native uses when running react-native run-ios, which had -destination id="{MyprojectID}" In doing so I removed -derivedDataPath iOS/build, I solved it by adding this again, together with -sdk iphonesimulator, with my build command looking like this:

xcodebuild -workspace iOS/{AppName}.xcworkspace -configuration Debug -scheme {AppName} -sdk iphonesimulator -derivedDataPath ios/build -destination id={MyprojectID}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Léo Natan
Solution 2