Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unrecognized font family 'Roboto' - React Native iOS

When building iOS app on React Native, the simulator launches successfully but the app reports an error: "Unrecognized font family 'Roboto'", 'Roboto-Thin', or some variation.

Screenshot below:

enter image description here

Command I ran:

react-native run-ios
like image 536
Luciano Gil Avatar asked Aug 29 '18 20:08

Luciano Gil


People also ask

How do I unlink fonts from react native?

Navigate to android/app/src/main/assets/fonts And remove the fonts you want out. And that'll be all.


2 Answers

Like @theoretisch and @JoseVf mentioned before I have, please provide more information and what you've tried so far.

By putting in time to ask a question, you will increase the chance of getting a good answer quickly. Also please refer to How do I ask a good question? section for more info on that.

All that said, in the spirit of helping you out the following would fix your issue.

Use fontFamily: 'System' instead of fontFamily: 'Roboto'

Explanation You are trying to find Roboto font on iOS where it's not included by default in the operating system. On Android however, it is.

So by giving fontFamily: 'System' you are saying to React Native pick the default system font family thats default to the current platform your running on. For iOS this is going to be San Francisco and for Android this will be Roboto

Note that if you want to show Roboto font family on both platforms (your design might be as such) then you need to include that said font in your react native app bundle and then you wouldn't get this issue.

like image 85
hdsenevi Avatar answered Oct 18 '22 20:10

hdsenevi


I had exactly same issue. Project building perfect in android and build failing in iOS.

To fix this I did these steps:

1) Added Roboto.tff file in <projectRoot>/assets/fonts folder

2) Added file in Xcode project Resources:

enter image description here

3) Added line <string>Roboto.ttf</string> in UIAppFonts key in Info.plist file

  <key>UIAppFonts</key>
  <array>
        ....
        <string>Roboto.ttf</string>
  </array>

4) Checked that file exists in Build Phases Copy Bundle Resources

enter image description here

Ran Product->Clean Build Folder, Restarted JS server, Rebuilt

like image 42
Florin Dobre Avatar answered Oct 18 '22 21:10

Florin Dobre