macOS Ventura+Xcode14下React Native iOS构建失败求助
React Native iOS构建失败问题排查求助
环境信息
- macOS Ventura V13
- XCode 14.0.1
- 通过
npx react-native init MyProject创建新项目 - 已按步骤更新Ruby版本,项目可正常构建,但执行
npx react-native run-ios编译失败
报错详情
命令行执行npx react-native run-ios报错
warn Multiple Podfiles were found: ios/Podfile,vendor/bundle/ruby/2.7.0/gems/cocoapods-core-1.11.3/lib/cocoapods-core/Podfile. Choosing ios/Podfile automatically. If you would like to select a different one, you can configure it via "project.ios.sourceDir". info Found Xcode workspace "myProject.xcworkspace" info Building (using "xcodebuild -workspace myProject.xcworkspace -configuration Debug -scheme myProject -destination id=") 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 myProject.xcworkspace. Command line invocation: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace myProject.xcworkspace -configuration Debug -scheme myProject -destination id= User defaults from command line: IDEPackageSupportUseBuiltinSCM = YES Prepare packages Computing target dependency graph and provisioning inputs Create build description Build description signature: Build description path: /Users/miguelito/Library/Developer/Xcode/DerivedData/myProject-cgujjydukqoyfycbyxyuqiquehll/Build/Intermediates.noindex/XCBuildData/fb-desc.xcbuild note: Building targets in dependency order CreateBuildDirectory /Users/miguelito/Library/Developer/Xcode/DerivedData/myProject-cgujjydukqoyfycbyxyuqiquehll/Build/Intermediates.noindex cd /Volumes/DeTodo/REACT\ NATIVE/myProject/ios builtin-create-build-directory /Users/miguelito/Library/Developer/Xcode/DerivedData/myProject-cgujjydukqoyfycbyxyuqiquehll/Build/Intermediates.noindex
控制台末尾警告
In file included from /Volumes/DeTodo/REACT NATIVE/myProject/ios/Pods/libevent/event-internal.h:43: /Volumes/DeTodo/REACT NATIVE/myProject/ios/Pods/libevent/defer-internal.h:44:11: warning: parameter 'deferred' not found in the function declaration [-Wdocumentation] @param deferred The struct event_callback structure to initialize. ^~~~~~~~ /Volumes/DeTodo/REACT NATIVE/myProject/ios/Pods/libevent/defer-internal.h:45:11: warning: parameter 'priority' not found in the function declaration [-Wdocumentation] @param priority The priority that the callback should run at. ^~~~~~~~ /Volumes/DeTodo/REACT NATIVE/myProject/ios/Pods/libevent/defer-internal.h:46:11: warning: parameter 'cb' not found in the function declaration [-Wdocumentation] @param cb The function to run when the struct event_callback executes. ^~ /Volumes/DeTodo/REACT NATIVE/myProject/ios/Pods/libevent/defer-internal.h:47:11: warning: parameter 'arg' not found in the function declaration [-Wdocumentation] @param arg The function's second argument. ^~~ In file included from /Volumes/DeTodo/REACT NATIVE/myProject/ios/Pods/libevent/select.c:57: /Volumes/DeTodo/REACT NATIVE/myProject/ios/Pods/libevent/include/event2/thread.h:187:11: warning: parameter 'base' not found in the function declaration [-Wdocumentation] @param base the event base for which to set the id function ^~~~ 52 warnings generated.
XCode中运行报错
**'CLOCK_REALTIME' macro redefined** in file included from /myProject/ios/Pods/RCT-Folly/folly/io/async/TimeoutManager.cpp:22: previous definition is here **'CLOCK_MONOTONIC' macro redefined** in file included from /myProject/ios/Pods/RCT-Folly/folly/io/async/TimeoutManager.cpp:22: in file included from /myProject/ios/Pods/Headers/Private/RCT-Folly/folly/Chrono.h:26: previous definition is here **'CLOCK_PROCESS_CPUTIME_ID' macro redefined** in file included from /myProject/ios/Pods/RCT-Folly/folly/io/async/TimeoutManager.cpp:22: in file included from /myProject/ios/Pods/Headers/Private/RCT-Folly/folly/Chrono.h:26: previous definition is here **'CLOCK_THREAD_CPUTIME_ID' macro redefined** in file included from /myProject/ios/Pods/RCT-Folly/folly/io/async/TimeoutManager.cpp:22: in file included from /myProject/ios/Pods/Headers/Private/RCT-Folly/folly/Chrono.h:26: previous definition is here .../ios/Pods/Headers/Private/RCT-Folly/folly/portability/Time.h:52:17: ***Typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t')***
核心错误
Typedef redefinition with different types ('uint8_t' (aka 'unsigned char') vs 'enum clockid_t')
错误文件路径:
- /myProject/ios/Pods/RCT-Folly/folly/io/async/TimeoutManager.cpp:22
- /myProject/ios/Pods/Headers/Private/RCT-Folly/folly/Chrono.h:26
其他问题
- 警告:Run script build phase 'Bundle React Native code and images'会在每次构建时运行,需添加输出依赖或取消勾选"Based on dependency analysis"
- 执行
npx react-native run-android报错,但Android Studio中运行项目正常
已尝试操作
- 搜索类似问题解决方案,调整React Native、Node、Brew的安装配置,均无效
- 更新Ruby版本后项目可正常构建,但iOS编译仍失败
疑问
是否应该完全移除React Native开发环境重新搭建?
内容的提问来源于stack exchange,提问作者Miguel Espeso
相关产品推荐
相关产品推荐

