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

时间:2018-02-03 19:33:00

标签: react-native

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

**npm i react-native-elements --save**

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

react-native run-ios

不确定如何解决此错误。

5 个答案:

答案 0 :(得分:13)

尝试运行以下命令 -

react-native link react-native-vector-icons

如果这不能解决您的问题,那么一旦使用

重建您的应用程序
react-native run-ios

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

答案 1 :(得分:7)

如果您来自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>

答案 2 :(得分:5)

只需将这些行添加到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>

答案 3 :(得分:2)

好的,对于那些认为上述答案没有帮助的人,我只是将其添加到了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>

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

答案 4 :(得分:0)

在文件夹 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>

然后在终端运行

cd ios
pod install
cd ..
cd react-native run-ios