crash during initalization in CGFontCreateFontsWithPath

Just updated app w/ Xcode 7, getting a crash on initialization in UIApplicationMain, seemingly due to fonts.

(I noticed that Xcode 7 put a customFonts entry in my main .xib file .. maybe related?)

+    <customFonts key="customFonts">
+        <mutableArray key="Helvetica.ttc">
+            <string>Helvetica</string>
+            <string>Helvetica</string>
+            <string>Helvetica</string>
+            <string>Helvetica-Bold</string>
+            <string>Helvetica-Bold</string>
+            <string>Helvetica-Bold</string>
+            <string>Helvetica-Bold</string>
+            <string>Helvetica</string>
+        </mutableArray>
+    </customFonts>


* thread #1: tid = 0x9f65, 0x000000010dc11c6b libc++abi.dylib`__cxa_throw, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2
    frame #0: 0x000000010dc11c6b libc++abi.dylib`__cxa_throw
    frame #1: 0x00000001106127c8 libFontParser.dylib`TFileDescriptorContext::TFileDescriptorContext(char const*) + 142
    frame #2: 0x00000001106125d0 libFontParser.dylib`TFileDataReference::TFileDataReference(char const*) + 116
    frame #3: 0x00000001106123e4 libFontParser.dylib`TFileDataSurrogate::TFileDataSurrogate(char const*, bool) + 144
    frame #4: 0x0000000110659487 libFontParser.dylib`TFont::CreateFontEntities(char const*, bool, TSimpleArray<TFont*>&, short, char const*, bool) + 1641
    frame #5: 0x0000000110611d68 libFontParser.dylib`TFont::CreateFontEntitiesForFile(char const*, bool, TSimpleArray<TFont*>&, bool, short, char const*) + 176
    frame #6: 0x0000000110611724 libFontParser.dylib`FPFontCreateFontsWithPath + 209
    frame #7: 0x000000011d9eaf0a libCGXType.A.dylib`create_private_data_with_path + 19
    frame #8: 0x000000010989afaa CoreGraphics`CGFontCreateFontsWithPath + 40
    frame #9: 0x0000000109876e6e CoreGraphics`CGFontCreateFontsWithURL + 377
    frame #10: 0x000000010ef34fb7 GraphicsServices`AddFontsFromURLOrPath + 123
    frame #11: 0x000000010ef389a1 GraphicsServices`__Initialize_block_invoke + 1189
    frame #12: 0x000000010d85980d libdispatch.dylib`_dispatch_client_callout + 8
    frame #13: 0x000000010d8455f9 libdispatch.dylib`dispatch_once_f + 543
    frame #14: 0x000000010ef3462c GraphicsServices`Initialize + 223
    frame #15: 0x000000010ce55bdf libobjc.A.dylib`_class_initialize + 679
    frame #16: 0x000000010ce5bffd libobjc.A.dylib`lookUpImpOrForward + 176
    frame #17: 0x000000010ce6a843 libobjc.A.dylib`objc_msgSend + 195
    frame #18: 0x000000010ae7a8fa UIKit`-[UIStatusBarForegroundStyleAttributes makeTextFontForStyle:] + 67
    frame #19: 0x000000010ae7a7f9 UIKit`-[UIStatusBarForegroundStyleAttributes textFontForStyle:] + 116
    frame #20: 0x000000010aa7b8f9 UIKit`-[UIStatusBarItemView textFont] + 70
    frame #21: 0x000000010aa9c4e2 UIKit`-[UIStatusBarServiceItemView updateForContentType:serviceString:serviceCrossfadeString:maxWidth:actions:] + 387
    frame #22: 0x000000010aa9c873 UIKit`-[UIStatusBarServiceItemView updateForNewData:actions:] + 434
    frame #23: 0x000000010aa7af6f UIKit`-[UIStatusBarItemView initWithItem:data:actions:style:] + 464
    frame #24: 0x000000010aa7acff UIKit`+[UIStatusBarItemView createViewForItem:withData:actions:foregroundStyle:] + 134
    frame #25: 0x000000010aa7ebe6 UIKit`-[UIStatusBarLayoutManager _createViewForItem:withData:actions:] + 163
    frame #26: 0x000000010aa7cf27 UIKit`-[UIStatusBarLayoutManager _prepareEnabledItemType:withEnabledItems:withData:actions:itemAppearing:itemDisappearing:] + 365
    frame #27: 0x000000010aa7ca3e UIKit`-[UIStatusBarLayoutManager prepareEnabledItems:withData:actions:] + 92
    frame #28: 0x000000010aa6c0d4 UIKit`-[UIStatusBarForegroundView _setStatusBarData:actions:animated:] + 182
    frame #29: 0x000000010aa6c355 UIKit`-[UIStatusBarForegroundView setStatusBarData:actions:animated:] + 307
    frame #30: 0x000000010aa91259 UIKit`__44-[UIStatusBar _prepareToSetStyle:animation:]_block_invoke + 360
    frame #31: 0x000000010a583090 UIKit`+[UIView(Animation) performWithoutAnimation:] + 65
    frame #32: 0x000000010aa90ced UIKit`-[UIStatusBar _prepareToSetStyle:animation:] + 816
    frame #33: 0x000000010aa8f527 UIKit`-[UIStatusBar _requestStyleAttributes:animationParameters:] + 369
    frame #34: 0x000000010aa8f38c UIKit`-[UIStatusBar requestStyle:animationParameters:] + 349
    frame #35: 0x000000010a4e4a5e UIKit`-[UIApplication _setStatusBarStyle:animationParameters:] + 202
    frame #36: 0x000000010a4e478b UIKit`-[UIApplication _updateCurrentStatusBarViewControllerAppearance] + 256
    frame #37: 0x000000010a543d70 UIKit`-[UIWindow _initWithFrame:debugName:scene:attached:] + 470
    frame #38: 0x000000010a543b94 UIKit`-[UIWindow _initWithFrame:debugName:attached:] + 62
    frame #39: 0x000000010a543b10 UIKit`-[UIWindow _initWithFrame:attached:] + 61
    frame #40: 0x000000010a543acd UIKit`-[UIWindow initWithFrame:] + 58

This is the debugger hitting a breakpoint, not a crash. You have presumably set a breakpoint on all exceptions, including for C++ (as opposed to just Objective-C). The thing is, unlike Objective-C, exceptions are sometimes used in "normal" situations by C++ code. They don't necessarily indicate an unrecoverable error or impending crash.


In general, unless you're debugging C++ code and specifically interested in the exceptions thrown by it, you should set your breakpoint to just stop on Objective-C exceptions. Ignore the C++ exceptions. They will most likely be caught and handled by the C++ code and not actually cause any problem.

I'm also seeing this. I just upgraded my device from iOS 8 to 9, and the issue suddenly started to occur. Did you by any chance resolve it?


No breaking on C++ exceptions didn't fix it. Also, I removed all custom fonts from my project, and that also did not eliminate the issue.


Funny enough, disabling "debug app" in my scheme prevents the crash from occurring. But that's obviously not an option as I won't be able to debug the app at all as I'm developing it.

I had similar case , and this answer saved my day . thnx alot 🙂

crash during initalization in CGFontCreateFontsWithPath
 
 
Q