Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom font in swift 4 make Fatal error: Unexpectedly found nil while unwrapping an Optional value

Tags:

ios

swift

uifont

I have to add custom font to my app. I added fonts to my project and listed infolist.

 enum Proxima: String {
        case regular = "Regular"
        func font(size: CGFloat) -> UIFont {
            return UIFont(name: "Proxima-\(rawValue)", size: size)!
        }
    }

Fatal error: Unexpectedly found nil while unwrapping an Optional value while calling

self.headTitle.font = UIFont.Proxima.regular.font(size: 30)

UPDATE

I added the target and also checked the copy bundle resources all are correct but still i got same error.

enter image description here enter image description here

info.plist

like image 289
Daliya chacko Avatar asked Jan 02 '23 02:01

Daliya chacko


1 Answers

Be sure that your files are added to your target

Also, don't forget to add them into the "Font provided by application" section of the Info.plist

like image 64
Thermech Avatar answered Feb 05 '23 19:02

Thermech