36

I followed the setup instructions in the NativeBase Docs and ran rnpm link. I am getting this error: Unrecognized font family ionicons

also checked by Xcode, the fonts are already in the build phase. What am I missing?

Supriya Kalghatgi
  • 371
  • 1
  • 3
  • 6

10 Answers10

83

For RN 0.60+ don't use react-native link ...! (see Autolinking)

Instead add this in your Podfile:

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

and run pod update (or pod install).

Furthermore add this in your 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>

(took from https://github.com/oblador/react-native-vector-icons#option-with-cocoapods)

Works fine in my project with:

"react": "16.9.0",
"react-native": "0.61.1",
"native-base": "2.13.8" (react-native-vector-icons@6.6.0),
Eddy
  • 862
  • 6
  • 6
  • 1
    I have tried every other solution and this is the only one that worked for react-native 0.61.5 – Tosh Velaga May 29 '20 at 08:40
  • Now It works properly on React Native 0.63.2 Thanks Man! – mmcib Oct 01 '20 at 18:57
  • 1
    This solved my problem after I have followed several answers and tutorials here on the internet, but although the application compile, all icons appear with a "?" In place of the image. You could tell me why this happens, if needed, I post a question with more detail. thankful @Eddy. – Armando Marques da S Sobrinho Apr 03 '21 at 12:55
20

Expanding on the exisiting answer and using the solution found on this github issue, do the following;

  1. Close the running packager
  2. Run react-native link react-native-vector-icons
  3. Then run react-native start --reset-cache
  4. Finally run react-native run-ios to restart the simulator
Duncan
  • 447
  • 3
  • 12
19

Use the Icon.loadFont() method to load the fonts.

Example (Add your 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();
Sergey Yarotskiy
  • 4,536
  • 2
  • 19
  • 27
Anjali Aggarwal
  • 611
  • 4
  • 8
6

if you are using 0.60 and above then you need to do the following step :-

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

and after this run below command:-

react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios

After clean and build. Run the ios app. This solution work for me :)

Pankaj Negi
  • 1,558
  • 1
  • 16
  • 23
2

This happens if you start your packager and then link packages through rnpm link.

This requires you to restart your packager and try again.

Supriya Kalghatgi
  • 1,155
  • 9
  • 10
2

Editing PodFile and adding pod RNVectorIcons not necessary because auto-linking will work fine after adding react-native-vector-icons

adding to PodFile will cause a warning after the next run with react-native run-ios:

Warning: following modules are linked manually: - react-native-vector-icons (to unlink run: "react-native unlink react-native-vector-icons"

Just add this line of codes to your info.plist that exist on ios/yourPorjectName/

find UIAppFonts and add codes inside :

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

worked with:

"react-native": "0.63.3",

"react-native-vector-icons": "^7.1.0"

nima
  • 7,796
  • 12
  • 36
  • 53
1

native-base has 'react-native-vector-icons' as dependency but if you are using react-native <=0.59.10 then you have link.

Just simple command :

react-native link react-native-vector-icons
Khurshid Ansari
  • 4,638
  • 2
  • 33
  • 52
0

I had same issue on my mac.solution :

  • Close the terminal window and simulator.

  • On the same folder which your project is situated write following.. React-native link react-native-vector-icons

  • then start the project by., React-native run-ios

udit naik
  • 1
  • 1
0

If your iOS project is using CocoaPods (contains Podfile) and linked library has podspec file, then react-native link will link the library using Podfile.

Add the comment below to the bottom of your podfile.

# Add new pods below this line

Then run "react-native link [package_name]"

This works for me.

0

Works for me :

  • Put Ionicons.loadFont()
  • Close and reopen your application
Spritrl
  • 77
  • 4
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - [From Review](/review/late-answers/31490067) – Barry Michael Doyle Apr 11 '22 at 08:58