Xcode 9 custom fonts not working

Viewed 8873

Custom fonts not working in Xcode 9. However if I open the same project in Xcode 8, the custom fonts work as expected

I've ran this piece of code to ensure the fonts show up:

NSArray *fontFamilies = [UIFont familyNames];

for (int i = 0; i < [fontFamilies count]; i++)
{
    NSString *fontFamily = [fontFamilies objectAtIndex:i];
    NSArray *fontNames = [UIFont fontNamesForFamilyName:[fontFamilies objectAtIndex:i]];
    NSLog (@"%@: %@", fontFamily, fontNames);
}

I've ensured the fonts are in the plist, checked target membership, and in the copy bundle resource section.

Is this an Xcode bug?

5 Answers

I have this issue ,,

make sure that you Click on your font folder to make sure they are included in your “Target Membership.”

enter image description here

Had the same problem after opening project in Xcode 9, solved it by reincluding the fonts. (deleted them, cleaned project, included them, built project).

Altough you got them checked in the target, but not visible to chose as custom font, you can try to specify the localization (above target check) to 'base' or some, it made them visible in Storyboards after that, but unable to load in code (at least in my case). However, reincluding is imo better way to go, it made everything OK.

I solved custom font issue in my projects using Xcode 9. Here are the following steps-

1- Add to the font in the bundle. 2- add in plist file font name under Fonts provided by application 3- Go to Target->build phase and add your font files.

Now you can run your project.It will show to the custom font in your application.

It presents a problem for the compiler if it is located inside a blue directory folder (apparently) I moved my font file outside the folder, build and problem solved (GRR!)

Related