Unhappy with the default font options available as you build your iOS app? You can add your own custom fonts by associating them via Xcode. To start, you will need the font files (.ttf or .otf) you are looking to embed. If you're looking for free fonts, Google Fonts or Fontsquirrel are great places to start.
To add fonts to Xcode, select File > Add Files to "MyApp" from the menu bar.
Add your font files to the project making sure Copy items if needed is selected.
The next step is configuring Info.plist. In Info.plist, add the key Fonts Provided By Application (UIAppFonts). Then, add each font you want to embed in your app.
To use your custom font in a label or other UI element, use the following code:
myLabel.font = UIFont(name: "OpenSans-Bold", size: 16)
Run your app and you should see your custom font!
Note: If you are developing a macOS app instead, follow the steps above but use NSFont
instead of UIFont
.