Xcode 15 not reflecting fonts used in storyboard
Asked Answered
C

3

14

I updated Xcode to version 15.

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

I understand a workaround would be to 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!

Canst answered 20/9, 2023 at 0:8 Comment(0)
D
4

EDIT: the issue is now resolved in Xcode 15.0.1. From release notes:

Fixed issue that caused Interface Builder documents using custom App fonts to load incorrect font at runtime. (116019276)


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)
Divided answered 27/9, 2023 at 16:3 Comment(2)
i accidentally updated my macos to sonoma and i dont had access to xcode 14 anymore i ran xcode 15 by excuting xcode script inside xcode.app file and now i have access to xcode 14.3.1 (both gui and command line) on macos sonoma until this issue get resolved from applePrenomen
I faced the same font issue, but after updating macOS Sonoma and Xcode this issue is fixed.Johnstone
B
4

What I did was create an extension for UILabel/UIButton and UITextField and expose this to the storyboard via @IBInspectable where I pass the size for the given custom font I need. Then you set this from the storyboard or xib and it should work like the one added programmatically.

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
        }
    }
}
Baikal answered 2/10, 2023 at 13:47 Comment(0)
D
0

https://developer.apple.com/documentation/xcode-release-notes/xcode-15_0_1-release-notes

in xcode 15.0.1 -> Interface Builder Resolved Issues Fixed issue that caused Interface Builder documents using custom App fonts to load incorrect font at runtime. (116019276)

Dealfish answered 17/10, 2023 at 14:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.