我按照NativeBase Docs中的设置说明运行了rnpm link
. 我收到此错误:
无法识别的字体系列离子
Xcode 也检查过,字体已经在构建阶段。我错过了什么?
我按照NativeBase Docs中的设置说明运行了rnpm link
. 我收到此错误:
无法识别的字体系列离子
Xcode 也检查过,字体已经在构建阶段。我错过了什么?
对于 RN 0.60+ ,请勿使用react-native link ...
!(见自动链接)
而是将其添加到您的Podfile
:
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
并运行pod update
(或pod install
)。
此外,将其添加到您的Info.plist
:
<key>UIAppFonts</key>
<array>
<string>AntDesign.ttf</string>
<string>Entypo.ttf</string>
<string>EvilIcons.ttf</string>
<string>Feather.ttf</string>
<string>FontAwesome.ttf</string>
<string>FontAwesome5_Brands.ttf</string>
<string>FontAwesome5_Regular.ttf</string>
<string>FontAwesome5_Solid.ttf</string>
<string>Foundation.ttf</string>
<string>Ionicons.ttf</string>
<string>MaterialIcons.ttf</string>
<string>MaterialCommunityIcons.ttf</string>
<string>SimpleLineIcons.ttf</string>
<string>Octicons.ttf</string>
<string>Zocial.ttf</string>
</array>
(取自https://github.com/oblador/react-native-vector-icons#option-with-cocoapods)
在我的项目中工作正常:
"react": "16.9.0",
"react-native": "0.61.1",
"native-base": "2.13.8" (react-native-vector-icons@6.6.0),
扩展现有答案并使用在此 github 问题上找到的解决方案,执行以下操作;
react-native link react-native-vector-icons
react-native start --reset-cache
react-native run-ios
重启模拟器使用Icon.loadFont()
方法加载字体。
示例(添加您的 App.tsx):
import AntDesign from 'react-native-vector-icons/AntDesign';
import Ionicons from 'react-native-vector-icons/Ionicons';
import Feather from 'react-native-vector-icons/Feather';
AntDesign.loadFont().then();
Ionicons.loadFont().then();
Feather.loadFont().then();
如果您使用的是 0.60 及更高版本,则需要执行以下步骤:-
<key>UIAppFonts</key>
<array>
<string>AntDesign.ttf</string>
<string>Entypo.ttf</string>
<string>EvilIcons.ttf</string>
<string>Feather.ttf</string>
<string>FontAwesome.ttf</string>
<string>FontAwesome5_Brands.ttf</string>
<string>FontAwesome5_Regular.ttf</string>
<string>FontAwesome5_Solid.ttf</string>
<string>Foundation.ttf</string>
<string>Ionicons.ttf</string>
<string>MaterialIcons.ttf</string>
<string>MaterialCommunityIcons.ttf</string>
<string>SimpleLineIcons.ttf</string>
<string>Octicons.ttf</string>
<string>Zocial.ttf</string>
</array>
在此之后运行以下命令:-
react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
清洁和构建后。运行 ios 应用程序。这个解决方案对我有用:)
如果您启动打包程序,然后通过rnpm link
.
这需要您重新启动打包程序并重试。
不需要编辑 PodFile 和添加 pod RNVectorIcons
,因为添加react-native-vector-icons后自动链接会正常工作
添加到 PodFile 将在下次运行后引发警告react-native run-ios
:
Warning: following modules are linked manually: - react-native-vector-icons (to unlink run: "react-native unlink react-native-vector-icons"
只需将这行代码添加到存在于 ios/yourPorjectName/ 上的info.plist
找到UIAppFonts并在里面添加代码:
<string>AntDesign.ttf</string>
<string>Entypo.ttf</string>
<string>EvilIcons.ttf</string>
<string>Feather.ttf</string>
<string>FontAwesome.ttf</string>
<string>FontAwesome5_Brands.ttf</string>
<string>FontAwesome5_Regular.ttf</string>
<string>FontAwesome5_Solid.ttf</string>
<string>Foundation.ttf</string>
<string>Ionicons.ttf</string>
<string>MaterialIcons.ttf</string>
<string>MaterialCommunityIcons.ttf</string>
<string>SimpleLineIcons.ttf</string>
<string>Octicons.ttf</string>
<string>Zocial.ttf</string>
曾与:
“反应原生”:“0.63.3”,
“反应原生矢量图标”:“^7.1.0”
我的 mac.solution 也有同样的问题:
关闭终端窗口和模拟器。
在您的项目所在的同一个文件夹上写以下.. React-native 链接 react-native-vector-icons
然后通过 React-native run-ios 启动项目
如果您的 iOS 项目使用 CocoaPods(包含 Podfile)并且链接库具有 podspec 文件,则 react-native 链接将使用 Podfile 链接库。
将下面的评论添加到您的 podfile 的底部。
# Add new pods below this line
然后运行“react-native link [package_name]”
这对我有用。
native-base 具有“react-native-vector-icons”作为依赖项,但如果您使用的是 react-native <=0.59.10,那么您有链接。
只是简单的命令:
react-native link react-native-vector-icons