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

标签 ios react-native react-native-ios react-native-cli

我刚刚更新到 RN v0.63.3。我遇到了 react-native run-ios 的问题在之前的 react-native 版本中,更改了应用程序的名称后,项目/方案有不同的名称,一直没有解决这个问题,大家都说升级。
现在在 v0.63.3 上仍然存在 react-native run-ios 之后构建失败的问题.这次的错误是:

** BUILD FAILED **

The following build commands failed: 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 normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (1 failure)


从 Xcode 内部构建/运行没有问题。仅适用于 react-native run-ios编辑:我认为可能存在一个问题,因为我只是在调用 react-native run-ios 全局安装了 cli。 .我相信使用全局安装。所以自从它过时以来,我在全局范围内卸载并尝试使用社区包 npx react-native run-ios .现在它给出了另一个comileC错误,但不同。

** BUILD FAILED **

The following build commands failed: CompileC /Users/Library/Developer/Xcode/DerivedData/App-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 normal x86_64 objective-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 normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (2 failures)


这完全扼杀了我快速迭代的能力,欢迎提出任何建议
react 原生:0.63.3
react-native-cli(全局):2.0.1
react 原生社区/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"
    }
}
在@Florin 的建议/过程之后,现在有 14 个构建错误(来自使用 npx react-native run-ios 构建):

** BUILD FAILED **

The following build commands failed: CompileSwift normal x86_64 /Users/Desktop/Development/App/node_modules/react-native-agora/ios/RCTAgora/Base/BeanCovertor.swift CompileSwift normal x86_64 /Users/Desktop/Development/App/node_modules/react-native-agora/ios/RCTAgora/Base/Callback.swift CompileSwift normal x86_64 /Users/Desktop/Development/App/node_modules/react-native-agora/ios/RCTAgora/Base/Extensions.swift CompileSwift normal x86_64 /Users/Desktop/Development/App/node_modules/react-native-agora/ios/RCTAgora/Base/MediaObserver.swift CompileSwift normal x86_64 /Users/Desktop/Development/App/node_modules/react-native-agora/ios/RCTAgora/React/PromiseCallback.swift CompileSwift normal x86_64 /Users/Desktop/Development/App/node_modules/react-native-agora/ios/RCTAgora/React/RCTAgoraRtcChannelModule.swift CompileSwift normal x86_64 /Users/Desktop/Development/App/node_modules/react-native-agora/ios/RCTAgora/React/RCTAgoraRtcEngineModule.swift CompileSwift normal x86_64 /Users/Desktop/Development/App/node_modules/react-native-agora/ios/RCTAgora/React/RCTAgoraRtcSurfaceViewManager.swift CompileSwift normal x86_64 /Users/Desktop/Development/App/node_modules/react-native-agora/ios/RCTAgora/Base/RtcChannel.swift CompileSwift normal x86_64 /Users/Desktop/Development/App/node_modules/react-native-agora/ios/RCTAgora/Base/RtcChannelEvent.swift CompileSwift normal x86_64 /Users/Desktop/Development/Slide/Slide/node_modules/react-native-agora/ios/RCTAgora/Base/RtcEngine.swift CompileSwift normal x86_64 /Users/Desktop/Development/App/node_modules/react-native-agora/ios/RCTAgora/Base/RtcEngineEvent.swift CompileSwift normal 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 normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler (14 failures)


完整的构建输出,只要它回到粘胶的终端,就在这里:https://pastebin.com/XenEszNe
Xcode 构建阶段:
enter image description here

最佳答案

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

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

  • 此时,您应该从两个命令中获得相同的输出。如果你得到一个错误
    仔细阅读整个错误消息,有很多机会注意到隐藏在错误日志中的模块存在问题。
    仔细查看您的错误消息,它看起来与派生数据/缓存或某些未更新的 pod 有关。
    如果您仍然遇到问题,请附上您的问题:
  • package.json内容,
  • 完整的错误信息和
  • Xcode 的内容->BuildPhases bundle 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
    
    更多信息在这里:
    https://react-native-community.github.io/upgrade-helper/?from=0.61.5&to=0.63.3
    清理 Podfile 后,清理缓存,运行 pod install并重建。
    此时大部分错误应该已经消失了。
    checkin Xcode 任何剩余的不需要的手动库链接并将其删除(支持自动链接的链接)并再次重建。
    如果仍然无法正常工作,请检查 project.pbxproj在 RN 升级助手中。
    一个一个地处理错误。它们中的大多数应该可以使用 RN 升级助手和其他 Stackoverflow 答案来修复。

    关于ios - 为什么升级到 0.63.3 后命令 'react-native run-ios' 构建失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64744928/

    相关文章:

    ios - 为什么在设置某个属性的属性时会调用 'didset'?

    ios - 在 xcode IOS 中锁定 React Native 版本

    ios - 监视文件更改时出错 : EMFILE {"code" :"EMFILE" ,"errno" :"EMFILE" ,"syscall" :"Error watching file for changes:" ,"filename": null}?

    reactjs - 你们如何测试复杂的 React Native 应用程序?

    iOS 使用 GLKMathUnproject 查找世界空间中的屏幕点

    objective-c - 获取应用程序的 iTunes 图稿

    ios - 如何使用贝塞尔曲线路径在 swift 4 中用箭头创建虚线?

    javascript - 如何从数组中仅获取经度和纬度

    ios - React Native在文本中不显示{this.state.age}

    android - 使 ListView 可点击 React Native