【问题标题】:Unrecognized font family Material Icons?无法识别的字体系列材料图标?
【发布时间】:2019-08-05 03:08:48
【问题描述】:

我是 React-Native 的新手,我已手动将 react-native-vector-icons 库添加到 Xcode 和 Android 工作室。如果使用 Xcode 运行代码,它会成功执行,没有任何问题。但是如果我尝试从终端(react-native run-ios)运行代码,它会在模拟器中显示“无法识别的字体系列材料”。但是如果我运行命令(react-native run-android),这同样有效。

请帮助我。 这是终端Error Screen shot 中显示的错误

** BUILD FAILED **


The following build commands failed:

    CompileC /Users/user/Documents/Test/JobsNProfiles/ios/build/Build/Intermediates.noindex/RNVectorIcons.build/Debug-iphonesimulator/RNVectorIcons.build/Objects-normal/x86_64/RCTFont+FA5.o /Users/user/Documents/Test/JobsNProfiles/node_modules/react-native-vector-icons/RNVectorIconsManager/RCTFont+FA5.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

【问题讨论】:

标签: react-native react-native-elements react-native-vector-icons


【解决方案1】:

我找到的解决方法是检查字体是否添加到Info.plist文件中的UIAppFonts数组中:

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

欲了解更多信息here

【讨论】:

  • 谢谢你的魅力,你拯救了我的一天
  • 这个文件在哪里?搜索 UIAppFonts 没有任何结果
【解决方案2】:

我不确定你的配置中究竟缺少什么,所以我将陈述我认为的所有情况:

  1. 删除 ios/build 文件夹,然后尝试自动链接:react-native link react-native-vector-icons

  2. 确保您已检查字体是否已复制到构建阶段的复制捆绑资源中。如果没有,请重新检查手动配置步骤。

  3. 确保终止打包程序并重新运行以使更改生效。

【讨论】:

  • 谢谢你,我已经删除了构建文件夹并重新构建它然后它的工作。
  • 对我不起作用。这个问题有新的修复吗?我已经搜索了几个小时没有成功。
  • 这个答案可能已经过时了……正确答案是stackoverflow.com/a/58640559/128346(Seishin 的回答)
【解决方案3】:

最简单的

您只需将以下内容添加到您的Podfile


# Normal
pod 'RNVectorIcons', :path => '../node_modules/react-native-vector-icons'


# If you are using monorepo
# pod 'RNVectorIcons', :path => '../../../node_modules/react-native-vector-icons'


然后运行

yarn podinstall

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-04-03
    • 1970-01-01
    • 2021-11-16
    • 2019-12-03
    • 2016-10-24
    • 2022-07-18
    • 2019-02-04
    • 1970-01-01
    相关资源
    最近更新 更多