DEV Community

Cover image for Add Custom Fonts in React Native 0.63 for iOS and android

Add Custom Fonts in React Native 0.63 for iOS and android

Aneeqa Khan on July 28, 2020

Adding Custom Fonts to React Native App is quite easy and only needs a few steps. I am writing down the steps I did to add custom fonts to my app. ...
Collapse
 
lauro235 profile image
Lauro

Hi there, would you be able to update your article to clarify where you mean when you say src/assets please

It would be useful to know the exact path for both android and ios users. Let's assume the user is using expo with npx create-react-native-app.

I'm not certain from your description where to create the folder.

Is it

root/android/app/src
mkdir assets && cd assets
mkdir fonts && cd fonts

add files to fonts directory...

?

Collapse
 
aneeqakhan profile image
Aneeqa Khan

Hi Lauro, Sorry it was confusing for you.
You need to create a src/assets folder on root directory level.
I'll update the article too.

Collapse
 
lauro235 profile image
Lauro

I see the update. Thank you!

Collapse
 
256hz profile image
Abe Dolinger • Edited

Very helpful thanks! Using RN 0.63.3, it looks like the XCode step is done for us at the linking step. Just have to remember to rebuild the app after.

Collapse
 
aneeqakhan profile image
Aneeqa Khan

Thanks!

Collapse
 
obkurucu_ profile image
ozankurucu

Thanks.

Collapse
 
waseemkhanyes profile image
Waseem

"unrecognize font family font_name"

this error occurs when i add custom fonts in react native project
if follow above all steps
please help

Collapse
 
aneeqakhan profile image
Aneeqa Khan

Please go through this link
hopefully it will solve your problem

Collapse
 
mathiuskormasela12 profile image
Mathius Kormasela

Thanks, you saved me

Collapse
 
das2108 profile image
DAS2108

Can you tell me where did I go wrong? I got these error message, while trying to > npm run ios after font installation.

error: Multiple commands produce '/Users/dimasaaron/Library/Developer/Xcode/DerivedData/MyDoctor-bdkqxzbburdzwqcuvezmrndxlkgj/Build/Products/Debug-iphonesimulator/MyDoctor.app/Info.plist':
1) Target 'MyDoctor' (project 'MyDoctor') has copy command from '/Users/dimasaaron/Documents/ReactNative/MyDoctor/ios/MyDoctorTests/Info.plist' to '/Users/dimasaaron/Library/Developer/Xcode/DerivedData/MyDoctor-bdkqxzbburdzwqcuvezmrndxlkgj/Build/Products/Debug-iphonesimulator/MyDoctor.app/Info.plist'
2) Target 'MyDoctor' (project 'MyDoctor') has process command with output '/Users/dimasaaron/Library/Developer/Xcode/DerivedData/MyDoctor-bdkqxzbburdzwqcuvezmrndxlkgj/Build/Products/Debug-iphonesimulator/MyDoctor.app/Info.plist'.

Collapse
 
aneeqakhan profile image
Aneeqa Khan

This error is because you might have duplicate resources. Check for duplicate resources in "Resource" folder in Xcode also try deleting content of "Derived Data" folder and run again.

Collapse
 
nxtsuki profile image
nxtsuki

Very nice thread, worked for me!

Collapse
 
aneeqakhan profile image
Aneeqa Khan

Thank you!

Collapse
 
hosar profile image
Hosar

Thanks a lot, it saved my day.

Collapse
 
dzulfahmi profile image
Fitra Zul Fahmi

Thanks

Collapse
 
dayrimax91 profile image
Dayri Garcia Brito

Me funcionó. Muchas gracias.

Collapse
 
cs1881 profile image
Charles

Nice concise for quick reminding ourselves the steps.

Collapse
 
kulsoom1 profile image
Kulsoom-1

This helps, thanks! But I guess linking is doing the ios part for us as well so no need to add font files in Build Phases.

Collapse
 
aneeqakhan profile image
Aneeqa Khan

ahan. Thats great then

Collapse
 
mango3ree profile image
Vlad

Thanks!Working

Collapse
 
aneeqakhan profile image
Aneeqa Khan

Glad to hear this :)

Collapse
 
das2108 profile image
DAS2108

Hi Aneeqa,
I Cant find Build Phase like your screencap in my xcode.
Could you please tell me, where I can find it?

Collapse
 
aneeqakhan profile image
Aneeqa Khan

you have to go into your project folder first in xCode then select your app target and there you will top tabs for "General", "Build Phases",... settings.

Collapse
 
muhsarip profile image
muhsarip

how about setup that font on android? should i setup via xcode too?

Collapse
 
enestatli profile image
enestatli

npx react-native link is enough for Android. XCode is a development environment for macOS used to develop iOS.

Collapse
 
hamidehdl profile image
Hamideh

Short and useful, thank you.

Collapse
 
aneeqakhan profile image
Aneeqa Khan

thank you! :)

Collapse
 
yasirshahzad profile image
Muhammad Yasir

Baji isko use kese kren fontFamily main yeh to btaen