找不到React / RCTDefines.h'文件(RN0.61)

时间:2019-10-14 09:05:29

标签: react-native react-native-ios

从RN0.60升级到RN0.61。由于以下问题,iOS编译失败:

/react-native/React/Base/RCTBridgeModule.h:10:9: 'React/RCTDefines.h' file not found

我知道这个breaking changes。 (已弃用React.xcodeproj)

尝试一些事情

  1. npx react-native-clean-project&重新设置项目
  2. 删除Pods /和Pod安装
  3. ...想法不完整...

这是我的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'

2 个答案:

答案 0 :(得分:1)

这是我花了整整一天的时间寻找原因的解决方案,




TLDR;

您需要为抱怨无法找到 React / {whatever.h}

的第3方/自定义库添加.podspec到podfile中

第三方图书馆

如果您使用的是第三方库(纱线/ NPM /等)

  1. 从其他第三方库(例如RNDeviceInfo / etc ..)复制podspec

  2. 通过替换一些项(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}"
  1. 向podfile添加新行 pod 'NoSupportedLib', :path => '../node_modules/NoSupportedLib'

  2. Pod安装

本地依赖项

在具有本地依赖项的情况下,您也应该这样做(而不是将.a文件添加到Xcode的链接框架和库中)。

  1. 按照上面介绍的相同步骤
  2. 在声明s.source和s.source_files的第2步中,应执行以下操作:(假设您要在同一自定义库路径中创建此custom.podspec,否则,您需要修改s.source path根据需要)
s.source            = { :http => 'file:' + __dir__ + '/' }
s.source_files  = "customLib/*.{h,m}"
  1. 将新行添加到podfile
pod 'customLib', :path => '../localDependency/customLib'


子点

我尝试在我的方案下添加 React 作为构建目标,这显然无济于事。我认为对于> = RN0.60的项目,我们打算使用ReactNative提供的autolinking吗?因此,保持我们的Xcode的链接框架和库干净。 enter image description here

答案 1 :(得分:0)

我前一段时间遇到过同样的问题。该问题已在以下时间得到解决:product > scheme > edit scheme,转到“构建”选项卡,然后将react添加为第一个目标。

enter image description here