Xcode 8.0 中的词法或预处理器问题



我正在使用 react native: 0.41.2, react: 15.4.2 和 cocoapods for firebase(https://github.com/evollu/react-native-fcm(。我在构建代码时遇到问题。'React/RCTEventEmitter.h', 'React/RCTBridgeModule.h', 'React/RCTViewManager.h', 'React/RCTDefines.h' 这些文件未被发现 运行项目时抛出错误。

但是这些文件已经通过单击带有该文件名的 ctrl 在我的项目中。图像

吊舱文件:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
source 'https://github.com/CocoaPods/Specs.git'
target 'Inspector' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!
  # Pods for Inspector
  react_native_path = "../node_modules/react-native"
  pod "React", :path => react_native_path, :subspecs => [
    'Core',
    'RCTActionSheet',
    'RCTAnimation',
    'RCTGeolocation',
    'RCTImage',
    'RCTLinkingIOS',
    'RCTNetwork',
    'RCTSettings',
    'RCTText',
    'RCTVibration',
    'RCTWebSocket'
  ]
  pod 'Firebase/Core'
  pod 'Firebase/Messaging'
  target 'Inspector-tvOSTests' do
    inherit! :search_paths
    pod 'Firebase/Messaging'
    # Pods for testing
  end
  target 'InspectorTests' do
    inherit! :search_paths
    pod 'Firebase/Messaging'
    # Pods for testing
  end
end

对于那些面临此问题的人来说,这是由于 react native 0.41.2 和 cocoapods 的标头导入问题要解决这些错误,请按照以下步骤操作

1 npm install -g react-native-git-upgrade

2 转到您的项目根文件夹并执行

react-native-git-upgrade

3 解决升级RN时发生的冲突

4 现在从 pod 文件中删除 React 依赖项,否则您将在方案中有两个 React(一个 RN 和一个 Pod(,这将在构建时导致no input error。您的 pod 文件应如下所示

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
source 'https://github.com/CocoaPods/Specs.git'
target 'Inspector' do
  # Uncomment the next line if you're using Swift or would like to use dynamic frameworks
  # use_frameworks!
  # Pods for Inspector   // Pods for your app, in this case firebase is used
  pod 'Firebase/Core'
  pod 'Firebase/Messaging'
  target 'Inspector-tvOSTests' do
    inherit! :search_paths
    pod 'Firebase/Messaging'
    # Pods for testing
  end
  target 'InspectorTests' do
    inherit! :search_paths
    pod 'Firebase/Messaging'
    # Pods for testing
  end
end

5 CD iOS 和 pod 安装

6 关闭 Xcode 并打开 .xcworkspace 文件

最新更新