React Native 在 Xcode 编译时错误 'event2/event-config.h' file not found
问题描述
项目环境:
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