[英]Can't build react-native app with xcode scheme and configuration
Currently i'm developing a react-native application for iOS which uses firebase as the backend.目前我正在为 iOS 开发一个 react-native 应用程序,它使用 firebase 作为后端。 To separate the 3 environments dev, staging, and prod i created 3 different schemas in xCode with 3 different run configurations.
为了分离 3 个环境 dev、staging 和 prod,我在 xCode 中使用 3 种不同的运行配置创建了 3 个不同的模式。
appNameDev => uses the debug run configuration
appNameStaging => uses the staging run configuration
appNameProd => uses the release run configuration
In the build phase i use this configuration to pick the right GoogleService-Info.plist在构建阶段,我使用此配置来选择正确的 GoogleService-Info.plist
case "${CONFIGURATION}" in
"Debug" )
echo "BUILD CONFIG: DEBUG"
cp -r "$PATH_TO_GOOGLE_PLISTS/Debug/GoogleService-Info.plist" "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/GoogleService-Info.plist" ;;
"Staging" )
echo "BUILD CONFIG: STAGING"
cp -r "$PATH_TO_GOOGLE_PLISTS/Staging/GoogleService-Info.plist" "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/GoogleService-Info.plist" ;;
"Release" )
echo "BUILD CONFIG: RELEASE"
cp -r "$PATH_TO_GOOGLE_PLISTS/Release/GoogleService-Info.plist" "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/GoogleService-Info.plist" ;;
*)
;;
esac
When i run the different builds from xCode everything works as expected当我从 xCode 运行不同的构建时,一切都按预期工作
When it try to run the build with different schemas from the command-line with the react-native cli当它尝试使用 react-native cli 从命令行运行具有不同架构的构建时
npx react-native run-ios --scheme appName[stage]
it always runs the app with the Debug configuration, which is shown by the xcode terminal output它始终使用调试配置运行应用程序,如 xcode 终端 output 所示
"xcodebuild -workspace appNameApp.xcworkspace -configuration Debug -scheme appNameStaging -destination id=simId"
“xcodebuild -workspace appNameApp.xcworkspace -configuration Debug -scheme appNameStaging -destination id=simId”
When i tried to add the configuration in the command当我尝试在命令中添加配置时
npx react-native run-ios --scheme appName[stage] --configuration Release
the build is successful, but the app is instantly crashing on start with the following error log构建成功,但应用程序在启动时立即崩溃并显示以下错误日志
Exception Type: EXC_CRASH (SIGABRT) Exception Codes: 0x0000000000000000, 0x0000000000000000 Exception Note: EXC_CORPSE_NOTIFY Termination Reason: DYLD 1 Library missing Library not loaded: @rpath/OpenSSL.framework/OpenSSL Referenced from: /Users/USER/Library/Developer/CoreSimulator/Devices/C7DABD19-235F-439E-95B6-3EA2607F037D/data/Containers/Bundle/Application/8463C40A-A7D3-4482-9BED-EC8938BB8483/appName.app/appName Reason: tried: '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/OpenSSL.framework/OpenSSL' (no such file), '/usr/lib/swift/OpenSSL.framework/OpenSSL' (no such file), '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/OpenSSL.framework/OpenSSL' (no such file), '/usr/lib/swift/OpenSSL.framework/OpenSSL' (no such file
异常类型:EXC_CRASH (SIGABRT) 异常代码:0x0000000000000000, 0x0000000000000000 异常说明:EXC_CORPSE_NOTIFY 终止原因:DYLD 1 Library missing Library not loaded:@rpath/OpenSSL.framework/OpenSSL 引用自:/Users/USER/Library/Developer/CoreSimulator/ Devices/C7DABD19-235F-439E-95B6-3EA2607F037D/data/Containers/Bundle/Application/8463C40A-A7D3-4482-9BED-EC8938BB8483/appName.app/appName 原因:试过:'/Applications/Xcode.app/Contents/Developer /Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/OpenSSL.framework/OpenSSL'(没有这样的文件),'/usr/lib /swift/OpenSSL.framework/OpenSSL'(没有这样的文件),'/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources /RuntimeRoot/usr/lib/swift/OpenSSL.framework/OpenSSL'(没有这样的文件),'/usr/lib/swift/OpenSSL.framework/OpenSSL'(没有这样的文件), '/Users/username/Library/Developer/CoreSimulator/Devices/C7DABD19-235F-439E-95B6-3EA2607F037D/data/Containers/Bundle/Application/8463C40A-A7D3-4482-9BED-EC8938BB8483/appName.app/F (terminated at launch;
), '/Users/username/Library/Developer/CoreSimulator/Devices/C7DABD19-235F-439E-95B6-3EA2607F037D/data/Containers/Bundle/Application/8463C40A-A7D3-4482-9BED-EC8938BB8483/appName.app/F (发射时终止; ignore backtrace)
忽略回溯)
You can fix this error by adding OpenSSL to Target's Frameworks & Libraries.您可以通过将 OpenSSL 添加到 Target 的框架和库来修复此错误。 Follow these steps in Xcode:
按照 Xcode 中的以下步骤操作:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.