skip to Main Content

I updated xcode to version 15.

My problem is when I run my application on both an iOS device and simulator, the fonts I had set via storyboard are not reflected properly. Does anyone know why?

I understand a workaround would be set the fonts programmatically, as I had found was described by Apple in their release notes, but i am really hoping to avoid that if a less tedious solution happens to exist!

2

Answers


  1. Unfortunately as you have stated, it’s a known issue in Xcode 15 since early betas, and still present in official release.

    Interface Builder documents using custom App fonts may load incorrect font at runtime. (113624207) (FB12903371)

    Workaround: Set font manually in code.

    I definitely hope a fix will come soon but since they seem to focus their efforts on SwiftUI nowadays, it could take timeā€¦

    Only workarounds currently are:

    • Set custom fonts in code (you might write an UILabel/UIButton subclass which sets a font by reading "User Defined Runtime Attributes" so you don’t have to pollute all your classes with font stuff)
    • Keep using Xcode 14 (be careful to not update to MacOS Sonoma, or you won’t be able to use Xcode 14 anymore)
    Login or Signup to reply.
  2. What I did was creating an extension for UILabel/UIButton and UITextField and exposing this to storyboard via @IBInspectable where I pass the size for the given custom font I need, then you set this from storyboard or xib and should work as the one with programatically added.

    extension UIButton {
    @IBInspectable
    var robotoMedium: CGFloat {
        set {
            titleLabel?.font = UIFont(name: "Roboto-Medium", size: newValue)
        }
        get {
            return 0.0
        }
    }
    
    @IBInspectable
    var robotoNormal: CGFloat {
        set {
            titleLabel?.font = UIFont(name: "Roboto-Regular", size: newValue)
        }
        get {
            return 0.0
        }
    }
    
    @IBInspectable
    var robotoBold: CGFloat {
        set {
            titleLabel?.font = UIFont(name: "Roboto-Bold", size: newValue)
        }
        get {
            return 0.0
        }
    }
    

    }

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search