简体   繁体   English

无法使用 xcode 方案和配置构建 react-native 应用程序

[英]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 中的以下步骤操作:

  1. Navigate to you project导航到您的项目
  2. Click on Target点击目标
  3. In "General" tab, scroll down to Frameworks, Libraries and Embedded Content" section.在“常规”选项卡中,向下滚动到“框架、库和嵌入式内容”部分。
  4. Click on "+" sign.点击“+”号。
  5. Search for "OpenSSL"搜索“OpenSSL”
  6. Add it添加它
  7. Run a new build运行一个新的构建

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 安装 react-native-firebase/app 后,Build 将在 react-native ios 中失败 - After installing react-native-firebase/app it's Build will failed in react-native ios 如果我使用 await,React-Native 应用程序将无法运行 - React-Native app doesn't work if i use await 无法将 Firestore 文档数据加载到 React-Native 中的变量 - Can't load firestore document data to variable in React-Native 在这种情况下,我可以为我的 react-native 应用程序使用本地通知吗? - Can I use local notifications in this case for my react-native app? React-Native 无法从 Firestore 响应中访问二级 - React-Native can't access second level from firestore response React-native 应用程序:navigation.navigate 不是 function - React-native app: navigation.navigate is not a function 在 Firebase React-Native 应用程序中按名称删除项目 - Remove item by name in Firebase React-Native app 没有重新渲染? Firebase和React-Native注册后登录 - Didn't rerender? Firebase and React-Native login after signup React-Native - 当我关闭像信使这样的应用程序时,我怎么可能仍然收到来自其他人的来电通知 - React-Native - How is it possible that when I close an app like messenger I can still receive incoming call notifications from others Firebase 是 react-native 后端 - Firebase are react-native backend
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM