I would like to report that as of this comment's writing, this approach of registering fonts after the app launches works only for SwiftUI apps, but not for UIKit apps which still use UIApplicationDelegate.
For SwiftUI apps, it does suffice to define a register() function in your Swift Package, which you should then call in the SwiftUI app's init(), as follows:
import MyCustomPackage
@main
struct SwiftUIDemoApp: App {
init() {
CustomFont.register()
}
}
The original poster @dokun1 already has a working implementation of the register() function.
However, UIKit apps seem to still require being configured as before, where font files must be in the application bundle and explicitly declared in the app target's Info.plist: https://developer.apple.com/documentation/uikit/text_display_and_fonts/adding_a_custom_font_to_your_app
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: