4

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.

Chrisissorry
  • 1,434
  • 2
  • 22
  • 43

4 Answers4

2

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.

Léo Natan
  • 56,823
  • 9
  • 150
  • 195
1

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}
0

I had the same issue for me issue is that I am trying to test wrong .app file. You can not test only .app file that is generated using right configuration. you can not use .app file that is created using adhoc certificate or npx react-native run-ios or build from Xcode. you has to use detox build command to generate .app file and that .app file path you has to give. Also debug configuration's .app will not work for release configuration and vice versa

Rajesh N
  • 6,198
  • 2
  • 47
  • 58
0

Make sure you first build the app and then run the tests.

detox build -c ios.sim.debug

This will build the bundle and create a binary at the path similar to:

"/Users/<YourName>/Library/Developer/Xcode/DerivedData/<AppName-xxxxxxxxxxxxxxxxxxxxxxxxxxxx>/Build/Products/Debug-iphonesimulator/<AppName>.app"

If you have used other simulators earlier make sure to delete contents of DerivedData folder so you can identify the path to the correct binary.

Then update this path in detoxrc.js under binaryPath and you should be able to build successfully.

apps: {
  'ios.debug': {
    binaryPath: "/Users/<YourName>/Library/Developer/Xcode/DerivedData/<AppName-xxxxxxxxxxxxxxxxxxxxxxxxxxxx>/Build/Products/Debug-iphonesimulator/<AppName>.app",
    build: "xcodebuild -workspace ios/<AppName>.xcworkspace -configuration debug -scheme <AppName> -sdk iphonesimulator -derivedDataPath -destination id=35B6BBB5-489F-738B-W846-3B577458462K",
    type: 'ios.app',
  },
  // Other configurations
}

You can finally run the tests:

detox test -c ios.sim.debug
Prince
  • 20,353
  • 6
  • 39
  • 59