PrideChung / FontAwesomeKit

Icon font library for iOS. Currently supports Font-Awesome, Foundation icons, Zocial, and ionicons.
MIT License
2.81k stars 307 forks source link

App Crashes on registerIconFontWithURL: in iOS 10 #97

Open vincilbishop opened 8 years ago

vincilbishop commented 8 years ago

FAKIcon.m:16: registerIconFontWithURL: CGFontRef newFont = CGFontCreateWithDataProvider(fontDataProvider); Crashes with little explanation. Was working fine in 9.3.2, but after upgrading to iOS 10, both older versions, and the new 2.2.0 crash on this line. The code seems to have been unchanged.

For some reason, I was able to follow the instructions in this SO post:

http://stackoverflow.com/questions/24900979/cgfontcreatewithdataprovider-hangs-in-airplane-mode

and call [UIFont familyNames]; before the registerIconFontWithURL: method was called, and the problem was solved. Weird.

evansobkowicz commented 8 years ago

I'm having this same issue. Wasn't able to fix it though.

iiAtlas commented 7 years ago

+1 on [UIFont familyNames], I call once in my AppDelegate and have no more issues. Bizarre.

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    //iOS 10 Random crash fix..........
    [UIFont familyNames];

    return YES;
}
helzapps commented 7 years ago

In order to fix this with a pod install using frameworks, the FontAwesome stuff is no longer in the mainBundle so the calls need to change from:

dispatch_once(&onceToken, ^{ [self registerIconFontWithURL: [[NSBundle mainBundle] URLForResource:@"zocial-regular-webfont" withExtension:@"ttf"]]; });

to:

dispatch_once(&onceToken, ^{ [self registerIconFontWithURL: [[NSBundle bundleForClass:[self class]] URLForResource:@"zocial-regular-webfont" withExtension:@"ttf"]]; });