Detox - 努力在基本的 iOS RN 应用程序上“构建二进制的 Detox 版本,并运行测试”
Posted
技术标签:
【中文标题】Detox - 努力在基本的 iOS RN 应用程序上“构建二进制的 Detox 版本,并运行测试”【英文标题】:Detox - Struggling to "build the Detox version of the binary, and run the tests" on a basic iOS RN app 【发布时间】:2021-04-26 11:51:47 【问题描述】:为您的帮助干杯。我对 Detox、React Native、Mac、Xcode 和在 *** 上发帖(新工作)非常陌生,如果我遗漏了细节,请道歉。
我正在遵循以下指南: https://reactnative.dev
我跑了
npx react-native init MyTestApp
并且有一个可以运行的 ios 应用程序,因为我可以启动捆绑程序并与演示应用程序交互。我大致了解发生了什么。
然后我开始按照这里的指南进行操作:
https://reactnativetesting.io/e2e/setup.html#installing-detox
我进入该部分:
$ detox build -c ios
$ detox test -c ios
对于我来说,我无法让 detox build -c ios 命令工作,输出如下:
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)
让我非常困惑的是我的 .detoxrc.json 似乎有正确的二进制路径,因为当我通过终端运行该命令时它可以工作,我(可能错误地)假设 Detox 正在修改此命令以使其失败?我读到你的 package.json 是由 detox build 读取的,但那里的命令也适用于 iOS。
我正在做一些超级愚蠢的事情,但我让自己陷入了困境,看不到答案。抱歉,如果已经存在类似的问题,我无法将任何事情与我的问题联系起来。再次为您提供的任何帮助而欢呼。
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"
【问题讨论】:
【参考方案1】:必须在构建步骤中添加“-UseModernBuildSystem=YES -arch x86_64”才能解决。
【讨论】:
伙计,你刚刚把我从一个深陷的深坑中救了出来。谢谢!这帮助我在 M1 上运行我的 detox 构建。以上是关于Detox - 努力在基本的 iOS RN 应用程序上“构建二进制的 Detox 版本,并运行测试”的主要内容,如果未能解决你的问题,请参考以下文章
无法在 IOS 应用程序的 detox 中使用深度链接 url 启动应用程序
我们可以在 Android 和 iOS 原生应用程序中使用 detox 工具吗? (不是反应本机)
执行“detox test”命令时,iOS 模拟器应用程序无法启动 #2305