iosxcodefontsinfo.plist

What else to check so that iOS app custom fonts will appear?


I am using Xcode 14.2 and building a SwiftUI application with 4 custom fonts. The fonts were previously loaded and usable in previews, but they are now oddly missing.

The following things are true:

  1. The fonts are listed as references in the file navigator. I have removed and re-added them.
  2. For each font file, TargetMembership is checked / true for the only target in the app
  3. The target's "Info" tab contains "Fonts provided by the application" with all 4 fonts listed as array elements and their filenames spelled correctly
  4. The target's Build Phases tab / Copy bundle resources lists all 4 fonts -- in addition to a couple images that are appearing correctly
  5. The entitlements file includes "Use fonts" and "Install fonts"
  6. Code that was correctly working earlier has not been changed; it is using the correct font names
  7. The following code does NOT list the custom fonts:
      .onAppear(){
        for family: String in UIFont.familyNames
        {
          print(family)
          for name: String in
                UIFont.fontNames(forFamilyName: family)
          {
            print("== \(name)")
          }
        }
  1. I have tried to view the build output but I cannot determine for sure what's in or out - everything's either bundled into the 14 GB(!) executable or in a .car database.

What else can I do to fix this? How can I keep from having to re-address this every couple weeks?


Solution

  • So, I asked ChatGPT. It's first suggestion was this:

    Clean and rebuild the project: Sometimes Xcode can have
    caching issues. Try cleaning your project by selecting
    "Product" from the Xcode menu, then choose "Clean Build 
    Folder." After cleaning, rebuild your project by selecting
     "Product" and then "Build."
    

    Ha! Great - the three-fingered solute! What is this Win95?

    1. I quit Xcode
    2. removed everything in ~/Library/Developer/Xcode/DerivedData
    3. Restarted Xcode
    4. Opened the project and built
    5. Got a build error with missing Info.plist and checked the target's Info tab and saw the Fonts key was missing (as noted above, it was previously there!)
    6. Added the `Fonts provided by the application` key
    7. Saw that my Fonts/ group had the wrong file for one of the files (as noted above, this was previously correct) so I deleted and added the correct reference
    8. Added each of the font filenames into the Info.plist "Fonts provided..." array
    9. Rebuilt
    10. Opened a view and unpaused the preview

    The fonts appeared!! Yay!

    Wow, that's 2 days of OCD hassle just lost. This never wouldda happened when they were NeXT...