React Native:RCT-Folly 致命错误 - 'fmt/compile.h' 找不到文件
React Native: RCT-Folly fatal error - 'fmt/compile.h' file not found
我想为我的 iOS React 本机项目启用 Hermes,但我遇到下一个错误:
In file included from ../ios/Pods/RCT-Folly/folly/Singleton.cpp:35:
../ios/Pods/RCT-Folly/folly/portability/FmtCompile.h:19:10: fatal error: 'fmt/compile.h' file not found
#include <fmt/compile.h>
^~~~~~~~~~~~~~~
我的配置:
System:
OS: macOS 11.6.1
Binaries:
Node: 12.22.7 - /usr/local/bin/node
npm: 6.14.15 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.10.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: ^0.66.3 => 0.66.3
我的播客文件:
platform :ios, '12.0'
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
use_frameworks!
workspace 'MyWorkspace'
# Default spec repo
source 'https://github.com/CocoaPods/Specs.git'
...
target 'MyTarget' do
project 'MyProject'
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => true
)
...
end
经过一些调查,我发现动态 linking (use_frameworks!
) 导致了这个问题,如果我 link pods 静态地一切正常。但是我必须为我的项目使用框架,那么如何解决这个问题?
只需为 post_install
中的 RCT-Folly
目标直接将 header 搜索路径设置为 fmt
来源即可解决此问题:
播客文件:
...
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'RCT-Folly'
target.build_configurations.each do |config|
config.build_settings['HEADER_SEARCH_PATHS'] = "$(inherited) ${PODS_ROOT}/fmt/include"
end
end
end
end
我想为我的 iOS React 本机项目启用 Hermes,但我遇到下一个错误:
In file included from ../ios/Pods/RCT-Folly/folly/Singleton.cpp:35:
../ios/Pods/RCT-Folly/folly/portability/FmtCompile.h:19:10: fatal error: 'fmt/compile.h' file not found
#include <fmt/compile.h>
^~~~~~~~~~~~~~~
我的配置:
System:
OS: macOS 11.6.1
Binaries:
Node: 12.22.7 - /usr/local/bin/node
npm: 6.14.15 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
Managers:
CocoaPods: 1.10.1 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: ^0.66.3 => 0.66.3
我的播客文件:
platform :ios, '12.0'
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
use_frameworks!
workspace 'MyWorkspace'
# Default spec repo
source 'https://github.com/CocoaPods/Specs.git'
...
target 'MyTarget' do
project 'MyProject'
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => true
)
...
end
经过一些调查,我发现动态 linking (use_frameworks!
) 导致了这个问题,如果我 link pods 静态地一切正常。但是我必须为我的项目使用框架,那么如何解决这个问题?
只需为 post_install
中的 RCT-Folly
目标直接将 header 搜索路径设置为 fmt
来源即可解决此问题:
播客文件:
...
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == 'RCT-Folly'
target.build_configurations.each do |config|
config.build_settings['HEADER_SEARCH_PATHS'] = "$(inherited) ${PODS_ROOT}/fmt/include"
end
end
end
end