react-native - 未找到 React/RCTDefines.h' 文件 (RN0.61)
问题描述
将 RN 从 RN0.60 升级到 RN0.61。由于以下问题,iOS 构建失败:
/react-native/React/Base/RCTBridgeModule.h:10:9: 'React/RCTDefines.h' file not found
我知道这种重大变化。(不推荐使用 React.xcodeproj)
尝试几件事
- npx react-native-clean-project & 重新设置项目
- 删除 Pods/ & pod install
- ……想不通了……
这是我的 podfile 的样子。
pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
pod 'React', :path => '../node_modules/react-native/'
pod 'React-Core', :path => '../node_modules/react-native/'
pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
pod 'ReactCommon/jscallinvoker', :path => '../node_modules/react-native/ReactCommon'
pod 'ReactCommon/turbomodule/core', :path => '../node_modules/react-native/ReactCommon'
pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
# Required by RNFirebase
pod 'Firebase/Core', '~> 6.9.0'
pod 'RNFirebase', :path => '../node_modules/react-native-firebase/ios'
pod 'Fabric', '~> 1.10.2'
pod 'Crashlytics', '~> 3.14.0'
# FBSDK
pod 'react-native-fbsdk', :path => '../node_modules/react-native-fbsdk'
pod 'react-native-netinfo', :path => '../node_modules/@react-native-community/netinfo'
pod 'react-native-image-picker', :path => '../node_modules/react-native-image-picker'
pod 'react-native-splash-screen', :path => '../node_modules/react-native-splash-screen'
pod 'react-native-webview', :path => '../node_modules/react-native-webview'
解决方案
这是我花了一整天时间挖掘原因后的解决方案
。
.
.
.
TLDR;
您需要为抱怨找不到React/{whatever.h}的任何第 3 方/自定义库添加 .podspec 到 podfile
第 3 方库
如果您使用的是3rd 方库(Yarn/NPM/etc)
从其他 3rd 方库(例如,RNDeviceInfo/etc..)复制 podspec
通过替换一些项目(s.name,s.source)创建自己的podspec
s.name = "NoSupportedLib"
s.source = { :git => "https://github.com/react-native-community/NoSupportedLibName.git", :tag => "v#{s.version}" }
您可能需要注意以下事项,因为并非所有依赖项都可能存储在文件夹路径下ios/**/your.m & your.h files
s.source_files = "ios/**/*.{h,m}"
将新行添加到 podfile
pod 'NoSupportedLib', :path => '../node_modules/NoSupportedLib'
吊舱安装
本地依赖
如果您有本地依赖项,您也应该这样做(而不是将 .a 文件添加到 Xcode 的链接框架和库中。)
- 按照上面描述的相同步骤进行操作
- 在您声明 s.source 和 s.source_files 的步骤 2 中,您应执行以下操作:(假设您在同一自定义库路径中创建此 custom.podspec,否则您需要修改 s.source 路径作为您的需要)
s.source = { :http => 'file:' + __dir__ + '/' }
s.source_files = "customLib/*.{h,m}"
- 将新行添加到 podfile
pod 'customLib', :path => '../localDependency/customLib'
分点
我尝试在我的方案下添加React作为构建目标,显然它没有帮助。我认为对于 >=RN0.60 的项目,我们打算使用ReactNative提供的自动链接?因此,要保持 Xcode 的链接框架和库干净。
推荐阅读
- java - 为什么纹理没有加载?我的世界 15.2 锻造 31.2
- java - 如何清理 HiveMQ 消息缓存目录?
- c# - 使用 findcontrol 在 gridview 中查找值并将其与数据库中的数据进行比较
- ios - 由于错误,无法序列化 JSON
- javascript - 如何将标记 D3.js 添加到地图?
- r - 在 R 中满足距离标准时如何停止聚类
- python-multithreading - 两个线程不能在python中共享数据
- ruby-on-rails - Devise-JWT:向“/users/sign_in”发出 AJAX 请求时无法访问授权标头
- arduino-c++ - Arduino C 语言使用 toCharArray() 不正确
- python - Tensorflow:如何使用来自另一个 Tensorflow 模型的输入来获得预训练 Keras 模型的正确输出