错误:安装react-native-elements后无法识别的字体系列Material Design图标?

Cur*_*ngs 2 react-native

我是反应原生的新手.我使用react-native-cli创建了一个新项目.我正在使用react-native-elements作为React Native的UI组件库.所以我运行了以下命令

**npm i react-native-elements --save**
Run Code Online (Sandbox Code Playgroud)

在此之后我运行了我的模拟器命令,

react-native run-ios

不确定如何解决此错误.

Zee*_*ari 31

如果您来自 react-native 0.60+,请在 info.plist 文件中添加 UIAppFonts(如下所述)。并将 node_modules/react-native-vector-icons 下的 fonts 文件夹拖放到 xcode 中的项目中。确保在“添加到目标”下选中了您的应用,如果添加整个文件夹,则选中“创建组”。

<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)


Abh*_*war 17

尝试运行以下命令 -

react-native link react-native-vector-icons
Run Code Online (Sandbox Code Playgroud)

如果这不能解决您的问题,那么一旦使用,重建您的应用程序,

react-native run-ios
Run Code Online (Sandbox Code Playgroud)

有时CLI无法自动获取更新.


hat*_*gic 14

只需在 info.plist 中添加这些行,删除build/文件夹内的ios文件夹并重建应用程序npx react-native run-ios 它对我有用。

<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)

  • 上面工作得很好。不必删除“ios”内的“build”文件夹 (2认同)

小智 12

将给定的代码添加到文件夹 yourAppName/info.plist 中的 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)

然后在终端运行

cd ios
pod install
cd ..
npx react-native run-ios //if react-native installed then just react-native run-ios
Run Code Online (Sandbox Code Playgroud)


Ian*_*sco 6

好的,对于没有发现上述答案有帮助的人,我只是将其添加到 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)

然后转到ios文件夹并运行 pod install。再次运行应用程序,它应该可以工作