无法识别的字体家族离子

Che*_*ana 9 react-native native-base

我按照NativeBase Docs中的设置说明运行rnpm link.我收到此错误: 无法识别的字体系列ionicons

也由Xcode检查,字体已经处于构建阶段.我错过了什么?

Dun*_*can 19

扩展现有答案并使用此github问题上的解决方案,执行以下操作:

  1. 关闭正在运行的打包器
  2. react-native link react-native-vector-icons
  3. 然后跑 react-native start --reset-cache
  4. 最后运行react-native run-ios重启模拟器


小智 13

对于RN 0.60+,请不要使用react-native link ...!(请参阅自动链接

而是将其添加到您的Podfile

pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'
Run Code Online (Sandbox Code Playgroud)

然后运行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>
Run Code Online (Sandbox Code Playgroud)

(取自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),
Run Code Online (Sandbox Code Playgroud)


小智 7

使用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();
Run Code Online (Sandbox Code Playgroud)

  • 这是 2021 年来这里的人的正确答案。 (4认同)

Pan*_*egi 5

如果您使用的是 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>
Run Code Online (Sandbox Code Playgroud)

并在此之后运行以下命令:-

react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios
Run Code Online (Sandbox Code Playgroud)

清洁和构建后。运行 ios 应用程序。这个解决方案对我有用:)


Sup*_*tgi 2

如果您启动打包程序然后通过 链接包,就会发生这种情况rnpm link

这需要您重新启动打包程序并重试。