Xcode 9 adds system fonts to the list of custom fonts

Originator:hugues.guillaume
Number:rdar://35989997 Date Originated:December 12 2017
Status:Duplicate of 35126633 Resolved:No
Product:Xcode Product Version:9.2
Classification:Bug Reproducible:Always
 
Summary:

When using a custom font in a storyboard, Xcode has a feature where this custom font is automatically added to the UIAppFonts array of the Info.plist (although this should be something already done by the developper).

In Xcode 8.3, if you select custom font in the right panel, you can choose between many fonts. It is expected that these fonts are provided by the system, meaning you can use them without providing the font file in your app resources.
In this list, you will also see any custom font that you have added to your project. When selecting one of these fonts, you will see that Xcode adds the following to the storyboard file:
    <customFonts key="customFonts">
        <mutableArray key="MyCustomFont.otf">
            <string>MyCustomFont</string>
        </mutableArray>
    </customFonts>
When building your project with such a storyboard, the font name (here MyCustomFont.otf) will be added automatically to UIAppFonts. Although this is something that should be done manually by the developper, this is most probably an intended feature.

In Xcode 9.2, whenever you select *any* font (including system fonts), the  <customFonts>...</customFonts> section is always added to the storyboard, and as a result the font file name is added to UIAppFonts.
At runtime, this triggers an exception deep inside UIKit because the file is missing from app resources. This exception is automatically caught, so this doesn't trigger a crash, however if you have an all exceptions breakpoint enabled, it stops your app every time you launch it, which quickly becomes annoying...

Steps to Reproduce:
 - Create a new single page iOS app
 - Add a label to the main storyboard and set a system custom font (Helvetica Neue for example)
 - Build the app and check the the generated Info.plist file contains a UIAppFonts font entry with the custom font (in this case: HelveticaNeue.ttc).
 - Add an all exceptions breakpoint and launch the app

Expected Results:
 - The Info.plist doesn't contain a UIAppFonts entry
 - The app launches and doesn't hit the breakpoint

Actual Results:
 - The Info.plist contains a UIAppFonts entry
 - The app launches and hits the breakpoint

Version/Build:
Xcode 9.2, iOS 11.2

Comments

"status: Duplicate of 35126633"
why can I find bug of 35126633?

By iamsuperdaemon at Jan. 16, 2018, 8:57 a.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!