Add custom font to Xcode (for LaunchScreen)

My app uses a custom font. I want to use this font in the LaunchScreen storyboard too. Anyone know how to do this?

I’ve got this far…

  1. I created a LaunchScreen storyboard in Xcode, using my custom font, and stored the storyboard file in my project repo.
  2. In CMake, I have the following to get the LaunchScreen.storyboard into Xcode. (I’m using Qt which provides support via a custom property.)
set_target_properties(MyTarget PROPERTIES
  QT_IOS_LAUNCH_SCREEN "${CMAKE_CURRENT_SOURCE_DIR}/LaunchScreen.storyboard"
)
  1. In CMake, I copy the font to the Resources folder
target_sources(MyTarget PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/MyFont.ttf")
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/MyFont.ttf" PROPERTIES
  MACOSX_PACKAGE_LOCATION Resources
)
  1. In Info.plist, I add the font
<key>UIAppFonts</key>
<array>
  <string>MyFont.ttf</string>
</array>

The only step that doesn’t work is step 3. Whereas this approach works fine for adding, say, an image to the built Resources folder, my font file doesn’t show up.

NB: When I originally added the font to Xcode to create the LaunchScreen storyboard, I followed these instructions from Apple. The first step adds the font file to Resources and adds it to MyTarget. Obviously every time I run CMake it recreates the Xcode project and so this font is lost, which is why I need to include it via CMake.

Resurrecting this old thread mostly for the benefit of others who might arrive here. You can’t actually set a custom font on a launch screen storyboard. The custom font isn’t loaded early enough to be used there. ios - LaunchScreen.xib not displaying my custom font - Stack Overflow

1 Like

Thanks, Craig. Good spot!