React Native 在 Xcode 编译时错误 'event2/event-config.h' file not found

React Native 2021-07-10 阅读 47 评论 0

问题描述

项目环境:
Xcode:12.4
React Native:0.63.2

今天把 React Native 项目下的 node_modules 文件夹删了,重新运行 yarn install && cd ios && rm -rf Pods && pod install ,Xcode 编译的时候,出现错误:'event2/event-config.h' file not found,如下图:

Podfile 文件内容如下:

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '11.0'

target 'test' do
  config = use_native_modules!

  use_react_native!(:path => config["reactNativePath"])

  target 'testTests' do
    inherit! :complete
    # Pods for testing
  end

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
  use_flipper!
  post_install do |installer|
    flipper_post_install(installer)
  end
end

target 'test-tvOS' do
  # Pods for test-tvOS

  target 'test-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end
end

解决方法1

删除 Flipper 模块。删除或者屏蔽 Podfile 文件的以下几行。

#  add_flipper_pods!
#  post_install do |installer|
#    flipper_post_install(installer)
#  end

解决方法2

保留 Flipper模块,升级并指定 Flipper-Folly 版本,比如 2.3.0,如下:

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable these next few lines.
- use_flipper!
+ use_flipper!({ 'Flipper-Folly' => '2.3.0' }) # update this part
  post_install do |installer|
    flipper_post_install(installer)
  end
最后更新 2021-07-10
MIP.watch('startSearch', function (newVal, oldVal) { if(newVal) { var keyword = MIP.getData('keyword'); console.log(keyword); // 替换当前历史记录,新增 MIP.viewer.open('/s/' + keyword, {replace: true}); setTimeout(function () { MIP.setData({startSearch: false}) }, 1000); } }); MIP.watch('goHome', function (newVal, oldVal) { MIP.viewer.open('/', {replace: false}); });