Xcode font disappeared

2020-08-12 09:14发布

问题:

I imported my fonts on my project (Roboto), it worked with my first ViewController, but now Roboto disappeared of my Custom Fonts. Now when I want to modify my font, the font changed to Helvetica.

I don't understand how it happened, I didn't change the fonts folder.

回答1:

I had the same problem, also using Roboto. After restarting Xcode the font reappeared.



回答2:

No need to reinstall the font, since it's already added to the project. Just quit Xcode and delete DerivedData then start Xcode again. The custom font should be ok. I delete the whole DerivedData folder, since Xcode will generate it automatically.

rm -rf ~/Library/Developer/Xcode/DerivedData



回答3:

Try to use the custom font on one of your UILabel through the storyboard, after that search for the custom font programatically:

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

You should be able to see the font you are looking for