React Native 0.73升级iOS构建报错:_OBJC_CLASS_$_RCTEventDispatcher未定义
React Native 0.73 iOS构建链接错误:OBJC_CLASS$_RCTEventDispatcher未定义解决方案
针对RN 0.73升级后App Center iOS流水线出现的_OBJC_CLASS_$_RCTEventDispatcher未定义链接错误(涉及RNReanimated和react-native-video),以下是几个针对性的排查和解决步骤:
确认Podfile依赖配置
确保所有相关target(主App target、ImageNotification等扩展target)都正确引入React Core模块。如果autolinking失效,可在Podfile中显式添加:target 'YourAppTarget' do pod 'React/Core', :path => '../node_modules/react-native/' # 其他依赖声明... end target 'ImageNotification' do pod 'React/Core', :path => '../node_modules/react-native/' pod 'RNReanimated', :path => '../node_modules/react-native-reanimated' end执行
pod install --repo-update重新安装依赖。彻底清理构建缓存
在App Center流水线中加入完整的清理步骤,避免缓存导致的依赖不一致:# 清理Pod依赖 cd ios && pod deintegrate rm -rf Pods/ Podfile.lock pod install --repo-update # 清理Xcode构建缓存 xcodebuild clean -workspace YourApp.xcworkspace -scheme YourAppScheme验证依赖版本兼容性
确保react-native-reanimated和react-native-video使用RN 0.73兼容版本:- react-native-reanimated需≥3.5.0
- react-native-video需≥6.2.0
重新安装依赖确保无残留:
npm uninstall react-native-reanimated react-native-video npm install react-native-reanimated react-native-video cd ios && pod install检查Xcode Target构建配置
对报错的target(主App、ImageNotification)检查以下Build Settings:Other Linker Flags:确保包含-ObjC和-lc++,且保留$(inherited)Framework Search Paths:添加$(inherited)和../node_modules/react-native/React路径
确认App Center构建环境
- 将Xcode版本升级至14.3及以上(RN 0.73官方推荐版本,最低14版本存在兼容性缺陷)
- 确保构建环境中Node版本锁定为18.x,避免版本波动
手动关联依赖库
打开Xcode工程,找到RNReanimated和react-native-video的target:- 进入
Build Phases→Link Binary With Libraries - 添加
libReact-Core.a(静态库模式)或React-Core.framework(动态库模式)
- 进入
内容的提问来源于stack exchange,提问作者Thanh Lai
相关产品推荐
相关产品推荐

