Patrick Haertel
Patrick Haertel

Reputation: 329

Custom Font Visible in Storyboard but not Simulator

For some reason, the font that I have added to the Xcode Project is showing in the Storyboard but not in the Simulator.

Here is the Storyboard.Storyboard Image

Here is the Simulator. Simulator Image

As you can see, the two fonts are not the same. I have seen similar posts on Stack Overflow, but all of these posts suggest solutions that I already have tried or made sure are enabled. I have made sure that the project is the target, it is in copy bundled resources, and it has been added to the info.plist. Here are some more screenshots: <code>P List</code> Image Target Membership Image <code>Copy Bundled Resources</code> Image

As this is a brand new project and I have only worked in storyboard mode, no code could be interfering with the text.

Upvotes: 7

Views: 2079

Answers (2)

Mojtaba Hosseini
Mojtaba Hosseini

Reputation: 120123

Troubleshooting

You can do this adding custom font to your project following:

  • Add all font files to your project navigator.
  • Add font names(with the file extension) to info.plist. (or do it in code, comment to ask me how)
  • Check if the font name matches the font name, not it's file name!
  • Check if each font is added to target.
  • Use following code to print out all fonts in the app:

anywhere after app lunched

for familyName in UIFont.familyNames {
    for fontName in UIFont.fontNames(forFamilyName: familyName) {
        print(fontName)
    }
}

Upvotes: 1

Patrick Haertel
Patrick Haertel

Reputation: 329

Thanks to @Ashley Mills, I was able to determine that the issue was I added the fonts in a folder and not independently. Adding the fonts separately fixed the issue.

Upvotes: 2

Related Questions