javascript - React Native 0.62.0 构建在 Xcode 13.1 上失败

标签 javascript react-native

我正在尝试在 Xcode 13.1 上运行我的项目,但问题是构建失败并显示消息:

error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening Ajman.xcworkspace. Run CLI with --verbose flag for more details.
Command line invocation:
    /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace Ajman.xcworkspace -configuration Debug -scheme Ajman -destination id=6C41B609-DA05-4FAD-98F3-CC0264871189

User defaults from command line:
    IDEPackageSupportUseBuiltinSCM = YES

note: Using new build system
note: Planning
Analyze workspace

Create build description
Build description signature: 1552deb311feffa24b258a2f780d63f1
Build description path: /Users/younisrahman/Library/Developer/Xcode/DerivedData/Ajman-gmdogtmpvnnzkcfzhirvzdbwaslh/Build/Intermediates.noindex/XCBuildData/1552deb311feffa24b258a2f780d63f1-desc.xcbuild

note: Build preparation complete
note: Building targets in parallel
CompileC /Users/younisrahman/Library/Developer/Xcode/DerivedData/Ajman-gmdogtmpvnnzkcfzhirvzdbwaslh/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/ReactCommon.build/Objects-normal/x86_64/RCTTurboModuleManager.o /Volumes/Software/Projects/React-Native/Ajman/node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'ReactCommon' from project 'Pods')
    cd /Volumes/Software/Projects/React-Native/Ajman/ios/Pods
    export LANG\=en_US.US-ASCII
.
.
.
.
.
The following build commands failed:
    CompileC /Users/younisrahman/Library/Developer/Xcode/DerivedData/Ajman-gmdogtmpvnnzkcfzhirvzdbwaslh/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/ReactCommon.build/Objects-normal/x86_64/RCTTurboModuleManager.o /Volumes/Software/Projects/React-Native/Ajman/node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'ReactCommon' from project 'Pods')
(1 failure)

最佳答案

# Add this code  bottom in Podfile
post_install do |installer|
  #Fix after updating to Xcode 13.1
  find_and_replace("../node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm",
 "_initializeModules:(NSArray<id<RCTBridgeModule>> *)modules", "_initializeModules:(NSArray<Class> *)modules")
 find_and_replace("../node_modules/react-native/ReactCommon/turbomodule/core/platform/ios/RCTTurboModuleManager.mm",
 "RCTBridgeModuleNameForClass(module))", "RCTBridgeModuleNameForClass(Class(module)))")
end

def find_and_replace(dir, findstr, replacestr)
 Dir[dir].each do |name|
     text = File.read(name)
     replace = text.gsub(findstr,replacestr)
     if text != replace
         puts "Fix: " + name
         File.open(name, "w") { |file| file.puts replace }
         STDOUT.flush
     end
 end
 Dir[dir + '*/'].each(&method(:find_and_replace))
end

# If not work try this 
change a parameter cast in the React module RCTTurboModuleManager.mm,

RCTBridgeModuleNameForClass(strongModule))

to

RCTBridgeModuleNameForClass(Class(strongModule)))

关于javascript - React Native 0.62.0 构建在 Xcode 13.1 上失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69994600/

相关文章:

reactjs - 命令行上的 Expo 与 Exp 之间的区别

image - React Native 中图像的分辨率应该是多少?

javascript - 如何使用 backbonejs 和 requirejs 动态加载 View 和模板

javascript - 防止 YUI 中关键监听器的默认行为

javascript - 重新加载页面后调用js函数

javascript - Jquery 对话框未使用 Angular 范围填充

react-native - React Native按比例缩放方形图像

c# - 如何在asp.Net中通过单击按钮打开弹出窗口

unit-testing - 将 Rewire 与 TypeScript 结合使用

react-native - 将 expo 项目移动到 react native 后收到警告 "componentWillReceiveProps has been renamed"