Swiftui Custom Fonts not showing

Hello, My Custom fonts are not showing in SwiftUI. I am all up to date on all of my software and I have added my TTF's to a fonts folder in my collection. I also added the "Fonts provided by application" array type to my info.plist and the fonts as elements. Here is my code. I have no idea what I'm doing wrong. Is there a bug in the latest version of Swiftui?

Code Block
Text("Hello World")
.font(.custom("VervelleScript-lgxR0", size: 36))

Did you check the correct fontname?

Did you read this? codewithchris.com/common-mistakes-with-adding-custom-fonts-to-your-ios-app/#findfontname


check the postscript name. it must be like the name of the font you add

I've been wrestling with this problem for a whole day. I finally solved it by changing the key name in the info.plist from "Fonts provided by application" to "UIAppFonts". Since new projects created with SwiftUI don't include an info.plist file, I suspect that I may have imported some outdated elements from an older plist file. When I tried adding the fonts via the property list UI, it added the "Fonts provided by application" key which seems obsolete and inappropriate for my project.

Hello all! The CodeWithChris link above is helpful even if it's not directly about SwiftUIm thanks.

For me, the breakthrough was realizing that you must not include the font path in the font item, i.e. "item 0" must be "MyFont.ttf" and not "custom_fonts/MyFont.ttf" -- contrary to what various tutorials have been telling me.

Also worth noting: in XCode 15 with an iOS app under SwiftUI, actually creating an Info.plist file caused build failures that were really hard to debug. Apparently Info.plist isn't the normal way anymore, and you need to add properties in the XCode UI directly for the target.

I'm running Xcode 15 and SwiftUI, and @biztos answer is what did the trick for me. All the tutorials I found talked about an info.plist file which doesn't exist anymore (at least not explicitly), and to add the full relative font path including the directory name the fonts are in.

The full gambit is to select your project in the project explorer (the left side panel that shows your files). Navigate to the Info tab, under the Custom iOS Target Properties section add a new string array key/value pair with the key name being "Fonts provided by application". Add each font file name without any paths associated with it. An additional step I found somewhere was to also add "Fonts" under the Signing & Capabilities section. I'm not sure if this was required or not bc I tried a lot of stuff before I got it working.

Side note: It wasn't clear for me how to add a new key to the info section. Just click the plus icon on any of the rows and it'll let you add a key. Not very clear UX but oh well.

The issue is with the relative path, by reading the documentation you may mistakenly think it's the Xcode folder path, but it's actually the path inside your target product app.

Swiftui Custom Fonts not showing
 
 
Q