Custom font iOS in Today Widget always return nil

I met this problem also, and I DID targeting font to my target and put fonts providing by application in plist. But still gets nil when I tried to retrieve font.

Maybe because the font name you're using is wrong.

For Example (also the problem I met)

The Font which I dragged into my project name is trenolt.otf

But Use this name UIFont(name: "trenolt", size: 14) gets nil

And According to Adding a Custom Font to Your App By Developer Documentation

I print out all the font familys and names

for family in UIFont.familyNames.sorted() {
  let names = UIFont.fontNames(forFamilyName: family)
  print("Family: \(family) Font names: \(names)")
}

Then I get in console

["TruenoLt", "TruenoRg"]

And now use the printed name

UIFont(name: "TruenoLt", size: 14)

Gets

<UICTFont: 0x7fbc39a168b0> font-family: "Trueno"; font-weight: normal; font-style: normal; font-size: 14.00pt

I had same problem and in my case adding full file name including file extension under the plist key Fonts provided by application worked for me. enter image description here


Maybe it's because you forgot to add key in your .plist file.

Add the key Fonts provided by application to a new row. Add items for each font you have added.