Search code examples
swiftxcode13

Adding custom font to Xcode 13+


Now that Apple has taken away the Plist, naturally it has changed the way we add custom fonts to our app. Before we just added the file to our bundle and set a property for it and our plist and viola..

Now I am curious.. can it be done without adding a custom plist as shown here or is that the only option?


Solution

    1. drag and drop your font-file into the project (make sure you hit copy if needed and check the target box)

    drag&drop

    1. choose Project -> Targets -> Info -> Custom iOS Target Properties and klick the small + icon under the "key" property. Start typing "Fonts provided by application"

    enter image description here

    1. enter the full font-filename inside this property-list

    enter image description here

    1. now you can use the font by its name

    2. (Bonus: if you have trouble to find the font name, you can print all available fonts with [see detail explanation for this at code with chris ]:

     for family: String in UIFont.familyNames
            {
                print(family)
                for names: String in UIFont.fontNames(forFamilyName: family)
                {
                    print("== \(names)")
                }
            }