为什么升级到 0.63.3 后命令“react-native run-ios”构建失败?

Jim*_*Jim 5 ios react-native react-native-ios react-native-cli

我刚刚更新到 RN v0.63.3。react-native run-ios更改应用程序名称后,我在以前的反应本机版本上遇到了问题,并且项目/方案有不同的名称,从未解决该问题,每个人都说只需升级即可。

现在在 v0.63.3 上仍然存在构建失败的问题react-native run-ios。这次的错误是:

** 构建失败 **

以下构建命令失败:CompileC /Users/vorousjames/Library/Developer/Xcode/DerivedData/<OLD_NAME>-gdmnlxiprekjqhfiueouiidqhqnl/Build/Intermediates.noindex/<NEW_NAME>.build/Debug-iphonesimulator/<NEW_NAME>.build/Objects- Normal/x86_64/AppDelegate.o /Users/Desktop/Development/App/iOS/<OLD_NAME>/AppDelegate.m 正常 x86_64 Objective-c com.apple.compilers.llvm.clang.1_0.compiler (1 次失败)

从 Xcode 内部构建/运行没有问题。只有react-native run-ios

编辑:我想也许是因为我在全局安装了 cli,因为我只是调用react-native run-ios. 我相信使用全局安装。因此,由于它已经过时,我全局卸载并尝试将社区包与npx react-native run-ios. 现在它给出了另一个 comileC 错误,但有所不同。

** 构建失败 **

以下构建命令失败:CompileC /Users/Library/Developer/Xcode/DerivedData/App-gdmnlxiprekjqhfiueouiidqhqnl/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RNFirebase.build/Objects-normal/x86_64/RNFirebaseMessaging.o /用户/桌面/开发/应用程序/node_modules/react-native-firebase/ios/RNFirebase/messaging/RNFirebaseMessaging.m正常x86_64目标-c com.apple.compilers.llvm.clang.1_0.compiler CompileC /Users/Library/Developer /Xcode/DerivedData/App-gdmnlxiprekjqhfiueouiidqhqnl/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RNFirebase.build/Objects-normal/x86_64/RNFirebaseFirestore.o /Users/Desktop/Development/App/node_modules/react-native -firebase/ios/RNFirebase/firestore/RNFirebaseFirestore.m 正常 x86_64 Objective-c com.apple.compilers.llvm.clang.1_0.compiler (2 次失败)

这完全扼杀了我快速迭代的能力,欢迎任何建议

反应原生:0.63.3 反应原生-cli(全局):2.0.1 反应原生社区/cli:^4.8.0 Xcode:12.0.1 iOS:14.0.1

更新:

包.json:

{
    "name": "Aflare",
    "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-native-community/cli": "^4.8.0",
        "@react-native-community/clipboard": "^1.2.2",
        "algoliasearch": "^3.16.0",
        "appcenter": "3.1.1",
        "appcenter-analytics": "3.1.1",
        "appcenter-crashes": "3.1.1",
        "axios": "^0.19.2",
        "moment": "^2.24.0",
        "moment-timezone": "^0.5.27",
        "prop-types": "^15.7.2",
        "react": "^16.13.1",
        "react-native": "^0.63.3",
        "react-native-agora": "^3.1.3",
        "react-native-algolia-dropdown": "^1.6.0",
        "react-native-calendars": "^1.220.0",
        "react-native-chart-kit": "^4.3.0",
        "react-native-code-push": "^6.0.0",
        "react-native-extended-stylesheet": "^0.12.0",
        "react-native-firebase": "^5.6.0",
        "react-native-gesture-handler": "^1.5.2",
        "react-native-image-crop-picker": "^0.26.1",
        "react-native-material-dropdown": "^0.11.1",
        "react-native-reanimated": "^1.4.0",
        "react-native-responsive-screen": "^1.4.1",
        "react-native-safe-area-context": "^0.6.2",
        "react-native-screens": "^1.0.0-alpha.23",
        "react-native-snap-carousel": "^3.8.4",
        "react-native-splash-screen": "^3.2.0",
        "react-native-svg": "^9.13.6",
        "react-native-view-shot": "^3.1.2",
        "react-native-webview": "^9.4.0",
        "react-navigation": "^4.0.2",
        "react-navigation-drawer": "^2.3.3",
        "react-navigation-stack": "^1.10.3",
        "react-redux": "^7.1.3",
        "redux": "^4.0.4",
        "redux-persist": "^6.0.0",
        "redux-thunk": "^2.3.0",
        "rn-fetch-blob": "^0.11.2"
    },
    "devDependencies": {
        "@babel/core": "7.8.4",
        "@babel/runtime": "7.8.4",
        "@react-native-community/eslint-config": "1.1.0",
        "@types/react": "^16.9.46",
        "@types/react-dom": "^16.9.8",
        "babel-jest": "^25.1.0",
        "eslint": "6.7.2",
        "jest": "^25.1.0",
        "metro-react-native-babel-preset": "0.59.0",
        "react-test-renderer": "16.13.1"
    },
    "jest": {
        "preset": "react-native"
    }
}
Run Code Online (Sandbox Code Playgroud)

在 @Florin 的建议/过程之后,现在有 14 个构建错误(来自使用 构建npx react-native run-ios):

** 构建失败 **

以下构建命令失败: CompileSwift 正常 x86_64 /Users/Desktop/Development/App/node_modules/react-native-agora/ios/RCTAgora/Base/BeanCovertor.swift CompileSwift 正常 x86_64 /Users/Desktop/Development/App/node_modules/react -native-agora/ios/RCTAgora/Base/Callback.swift CompileSwift 正常 x86_64 /Users/Desktop/Development/App/node_modules/react-native-agora/ios/RCTAgora/Base/Extensions.swift CompileSwift 正常 x86_64 /Users/Desktop /Development/App/node_modules/react-native-agora/ios/RCTAgora/Base/MediaObserver.swift CompileSwift 正常 x86_64 /Users/Desktop/Development/App/node_modules/react-native-agora/ios/RCTAgora/React/PromiseCallback。 swift CompileSwift 正常 x86_64 /Users/Desktop/Development/App/node_modules/react-native-agora/ios/RCTAgora/React/RCTAgoraRtcChannelModule.swift CompileSwift 正常 x86_64 /Users/Desktop/Development/App/node_modules/react-native-agora/ ios/RCTAgora/React/RCTAgoraRtcEngineModule.swift CompileSwift 正常 x86_64 /Users/Desktop/Development/App/node_modules/react-native-agora/ios/RCTAgora/React/RCTAgoraRtcSurfaceViewManager.swift CompileSwift 正常 x86_64 /Users/Desktop/Development/App/ node_modules/react-native-agora/ios/RCTAgora/Base/RtcChannel.swift CompileSwift 正常 x86_64 /Users/Desktop/Development/App/node_modules/react-native-agora/ios/RCTAgora/Base/RtcChannelEvent.swift CompileSwift 正常 x86_64 / Users/Desktop/Development/Slide/Slide/node_modules/react-native-agora/ios/RCTAgora/Base/RtcEngine.swift CompileSwift 正常 x86_64 /Users/Desktop/Development/App/node_modules/react-native-agora/ios/RCTAgora /Base/RtcEngineEvent.swift CompileSwift 正常 x86_64 /Users/Desktop/Development/App/node_modules/react-native-agora/ios/RCTAgora/Base/RtcSurfaceView.swift CompileC /Users/Library/Developer/Xcode/DerivedData/<Old_App_Name> -gdmnlxiprekjqhfiueouiidqhqnl/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RNFirebase.build/Objects-normal/x86_64/RNFirebaseMessaging.o /Users/Desktop/Development/App/node_modules/react-native-firebase/ios/RNFirebase /messaging/RNFirebaseMessaging.m 正常 x86_64 Objective-c com.apple.compilers.llvm.clang.1_0.compiler (14 次失败)

完整的构建输出,就其在粘胶终端中返回而言,位于: https: //pastebin.com/XenEszNe

Xcode 构建阶段: 在此输入图像描述

Flo*_*bre 5

大多数时候,当我从控制台构建和 Xcode 构建获得不同的输出时,我怀疑存在缓存问题,并使用后续步骤来解决该问题:

  • 停止JS服务器
  • 删除 Xcode 中的派生数据
  • 跑步pod install
  • 重新安装node_modules(可选)
  • npx watchman watch-del-all && yarn start --reset-cache
  • 使用控制台构建并使用 Xcode 构建

此时,两个命令的输出应该相同。如果出现错误,请仔细阅读整个错误消息,有很多机会注意到隐藏在错误日志深处的模块的问题。

仔细查看您的错误消息,它看起来像是与派生数据/缓存或某些未更新的 Pod 相关的内容。

如果您仍然遇到问题,请附上您的问题:

  • package.json内容,
  • 完整的错误消息和
  • Xcode->BuildPhasesbundle react-native code and images脚本的内容。

更新:

如果升级到 0.63.3 后您发现许多与 React 依赖项相关的问题,请确保 pod 文件是干净的并且仅包含您的特殊依赖项(不支持自动链接的依赖项或文档指定需要添加的依赖项) Podfile),但不包括 React 的。它应该看起来像这样:

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '10.0'

target 'YourRnApp' do
  config = use_native_modules!

  use_react_native!(:path => config["reactNativePath"])

  target 'YourRnAppTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  use_flipper!
  post_install do |installer|
    flipper_post_install(installer)
  end
end

target 'YourRnApp-tvOS' do
  # Pods for RnDiffApp-tvOS

  target 'RnDiffApp-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end
end
Run Code Online (Sandbox Code Playgroud)

更多信息请点击这里:

https://react-native-community.github.io/upgrade-helper/?from=0.61.5&to=0.63.3

清理Podfile、清理缓存后,运行pod install并重建。

此时大部分错误应该都消失了。

在 Xcode 中检查任何剩余的不需要的手动库链接并将其删除(支持自动链接的链接)并再次重建。

如果仍然无法正常工作,请检查project.pbxprojRN 升级助手中的 。

把错误一一指出来。其中大多数应该可以使用 RN 升级助手和其他 Stackoverflow 答案来修复。