Search code examples
javascriptreact-nativedetox

Detox - Struggling to "build the Detox version of the binary, and run the tests" on a basic iOS RN app


Cheers for your help. I'm super new to Detox, React Native, Macs, Xcode and posting on StackOverflow (new job), apologies if I'm missing details.

I'm following the guides from: https://reactnative.dev

I've ran

npx react-native init MyTestApp

And have a working iOS app, in that I can start the bundler and interact with the demo app. I loosely get what is going on.

I then started following the guide here:

https://reactnativetesting.io/e2e/setup.html#installing-detox

I get to the section:

$ detox build -c ios

$ detox test -c ios

And for the life of me I can't get the detox build -c ios command to work, the output is as follows:

clang: error: linker command failed with exit code 1 (use -v to see invocation)

warning: no rule to process file '/*****/*********/*****************/JamesReactNativeTest/ios/Pods/Flipper-RSocket/rsocket/benchmarks/CMakeLists.txt' of type 'text' for architecture 'arm64' (in target 'Flipper-RSocket' from project 'Pods')
warning: no rule to process file '/*****/*********/*****************/JamesReactNativeTest/ios/Pods/Flipper-RSocket/rsocket/benchmarks/README.md' of type 'net.daringfireball.markdown' for architecture 'arm64' (in target 'Flipper-RSocket' from project 'Pods')
warning: no rule to process file '/*****/*********/*****************/JamesReactNativeTest/ios/Pods/Flipper-RSocket/rsocket/README.md' of type 'net.daringfireball.markdown' for architecture 'arm64' (in target 'Flipper-RSocket' from project 'Pods')
warning: no rule to process file '/*****/*********/*****************/JamesReactNativeTest/ios/Pods/Flipper-RSocket/rsocket/benchmarks/CMakeLists.txt' of type 'text' for architecture 'x86_64' (in target 'Flipper-RSocket' from project 'Pods')
warning: no rule to process file '/*****/*********/*****************/JamesReactNativeTest/ios/Pods/Flipper-RSocket/rsocket/benchmarks/README.md' of type 'net.daringfireball.markdown' for architecture 'x86_64' (in target 'Flipper-RSocket' from project 'Pods')
warning: no rule to process file '/*****/*********/*****************/JamesReactNativeTest/ios/Pods/Flipper-RSocket/rsocket/README.md' of type 'net.daringfireball.markdown' for architecture 'x86_64' (in target 'Flipper-RSocket' from project 'Pods')
warning: Capabilities for Signing & Capabilities may not function correctly because its entitlements use a placeholder team ID. To resolve this, select a development team in the JamesReactNativeTest editor. (in target 'JamesReactNativeTest' from project 'JamesReactNativeTest')
** BUILD FAILED **


The following build commands failed:
        Ld /*****/*********/*****************/JamesReactNativeTest/ios/build/Build/Intermediates.noindex/JamesReactNativeTest.build/Debug-iphonesimulator/JamesReactNativeTest.build/Objects-normal/arm64/Binary/JamesReactNativeTest normal arm64
(1 failure)

What's super confusing to me is my .detoxrc.json seems to have the right binary path because when I run that command via the terminal it works, I (probably wrongly) assume Detox is amending this command to make it fail? I read that your package.json is read by detox build but the command there for iOS works too.

I'm doing something super silly but I've got myself into a spin and can't see the answer. Apologies if a similar question exists already, I couldn't tie anything to my problem. Cheers again for any help you can offer.

detoxrc.json

{
  "testRunner": "jest",
  "runnerConfig": "e2e/config.json",
  "configurations": {
    "ios": {
      "type": "ios.simulator",
      "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/JamesReactNativeTest.app",
      "build": "xcodebuild -workspace ios/JamesReactNativeTest.xcworkspace -scheme JamesReactNativeTest -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build",
      "device": {
        "type": "iPhone 11"
      }
    },
    "android": {
      "type": "android.emulator",
      "binaryPath": "SPECIFY_PATH_TO_YOUR_APP_BINARY",
      "device": {
        "avdName": "Pixel_2_API_29"
      }
    }
  }
}

package.json

{
  "name": "JamesReactNativeTest",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "react": "16.13.1",
    "react-native": "0.63.4",
    "react-native-macos": "^0.63.0-0"
  },
  "devDependencies": {
    "@babel/core": "^7.12.10",
    "@babel/runtime": "^7.12.5",
    "@react-native-community/eslint-config": "^2.0.0",
    "babel-jest": "^26.6.3",
    "detox": "^18.2.2",
    "eslint": "^7.17.0",
    "eslint-plugin-detox": "^1.0.0",
    "jest": "^26.6.3",
    "jest-circus": "^26.6.3",
    "metro-react-native-babel-preset": "^0.64.0",
    "react-test-renderer": "16.13.1"
  },
  "jest": {
    "preset": "react-native"
  }
}


Solution

  • Had to add "-UseModernBuildSystem=YES -arch x86_64" to the build step to resolve.