Where the build writes the fonts, images and icons of an iOS app, and how to add them to an Xcode project for UIKit and SwiftUI.
This documentation is a work in progress. Some information may be incomplete, outdated, or differ from the current product behavior.
Introduction
The build writes the files of an iOS app to dist/ios/<app>/<brand>/. The names are in snake_case, and an @2x or @3x indicator stays at the end of a name, which is how UIKit finds the variant of a screen. iOS gets the TTF and OTF fonts with their licenses, every image format but WebP, and the SVG, PDF and PNG files of icons/.
dist/ios/<app>/<brand>/
├── fonts/
├── icons/
└── images/The build copies, renames and sorts the files. It writes asset catalogs only with the --asset-catalog and --icon-catalog options, does not turn an SVG into a PDF and does not resize an image: an image has the variants the designer exported. This page says what you do with the files in Xcode.
Installation
An app gets the files in one of three ways: from the archive of a release, from a submodule that the app builds, or from a build of a clone. The commands of this page use mobile and acme, the iOS app and a brand of the configuration of the quick start; use the names of your chassis.build block in their place. The file names of the samples, such as images/hero_banner.png, are examples: your output has the files of your source, under the names that Output names describes.
Release archive
An archive needs no Node.js and no Git LFS on the machine that builds the app. Each GitHub release of a repository of assets has one archive per job attached, named <name>-<platform>-<app>-<brand>-<version>.zip after the name and the version of its package.json. The archive of an iOS job holds the content of dist/ios/<app>/<brand>/ at its top level, so it unpacks to fonts/, Assets.xcassets and Icons.xcassets. The release workflow that chassis-assets init writes builds with the build:release script, which passes --asset-catalog and --icon-catalog. A file without a place in a catalog stays in images/ or icons/, and a repository that takes the options out of the script has these folders in place of the catalogs.
Git submodule
A submodule pins the assets to a commit of the app's repository, and the app builds them. Install Git LFS first, since the fonts and the raster images are Git LFS files, then add the repository of assets and pull its files. The address is an example; use the one of your repository of assets:
git lfs install
git submodule add https://github.com/acme/acme-assets.git vendor/assets
git -C vendor/assets lfs pullAn Xcode project has no package.json, so the package @chassis-ui/assets is installed in the submodule, whose package.json lists it and which brings nothing else. The build needs Node.js 22.12 or later, and runs from the root of the submodule:
cd vendor/assets
npm install
npx chassis-assets build --platform ios # Every iOS job
npx chassis-assets build --platform ios --app mobile --brand acme # One jobA filtered build keeps the rest of dist/; add --clean to remove the folder of the selected jobs first. The build system page has every option.
Build from a clone
A clone in the same folder works the same way, and suits a team that changes the assets and the app together but keeps them in separate histories: run git clone https://github.com/acme/acme-assets.git vendor/assets in place of git submodule add, then the same commands.
The paths of dist/ on this page are relative to vendor/assets/.
A clone made without Git LFS holds pointer files in place of the fonts and the raster images. The build fails and lists them; run git lfs pull.
Output layout
Each job has one folder, dist/ios/<app>/<brand>/, with a folder per type and the subfolders of source/ kept. For a source with two font roles, a few images, a few icons and a data/ folder, the build writes:
dist/ios/<app>/<brand>/
├── data/
│ └── country_list.json
├── fonts/
│ ├── code_license.txt
│ ├── code_normal.ttf
│ ├── ui_license.txt
│ ├── ui_normal.ttf
│ ├── ui_normal_italic.ttf
│ └── ui_strong.ttf
├── icons/
│ ├── arrow_right_outline.svg
│ ├── arrow_right_solid.svg
│ └── ...
└── images/
├── hero_banner.png
├── hero_banner@2x.png
├── hero_banner@3x.png
├── logo/
└── onboarding/The type of a file decides whether iOS gets it:
| Type | Formats iOS gets | Formats iOS does not get |
|---|---|---|
fonts/ | .ttf, .otf, and the .txt licenses | WOFF, WOFF2 and the font stylesheets |
images/ | Every format but WebP | .webp |
icons/ | .svg, .pdf, .png | Every other format |
| Any other folder | Every file | None |
Output names
An app reads a file by its path in the folder of the job, and the build derives that path from the source. A file of source/<brand>/<app>/<type>/ or source/_default/<app>/<type>/, or of the _shared/<type>/ folder of either brand, is at <type>/ of the job, in the same subfolders, with its name in snake_case. The build renames files, not folders: HeroBanner@2x.png becomes hero_banner@2x.png, the indicator stays, and a dot inside a name becomes an underscore. A path so stays the same in every brand that has the file, whether the file comes from the folder of the brand or from the default brand.
To find the name of a file, list the output of the job:
find dist/ios/mobile/acme -name 'hero_banner*'Fonts
The font files are named by role and weight, not by family: ui_normal.ttf, ui_strong_italic.ttf, code_normal.ttf. Which family a role holds is the choice of the brand, so the app refers to the file of a role and reads the name of the font from it. A brand that holds a file for every role, as the fonts page describes, gives a role in the family of another role copies with one PostScript name. Listing or registering both files is harmless: the second one reports a duplicate name and the font loads. The roles are those of Chassis Tokens, and the fonts page lists what each platform gets.
Add the fonts
Xcode has to copy the fonts into the app bundle, and iOS has to be told about them. Add the files of dist/ios/<app>/<brand>/fonts/ to the project with File → Add Files to…, with the app target checked, then list each file under UIAppFonts (Fonts provided by application) in Info.plist, by its file name with the extension. A font that the bundle holds and the list does not name does not load:
<key>UIAppFonts</key>
<array>
<string>ui_normal.ttf</string>
<string>ui_normal_italic.ttf</string>
<string>ui_strong.ttf</string>
<string>code_normal.ttf</string>
</array>Each role that has files has a license, such as ui_license.txt and code_license.txt. Keep it with the fonts when you copy them, and add it to the app where the license of the family asks for it.
PostScript names
UIKit and SwiftUI load a custom font by its PostScript name, which is inside the file and is not the file name. On a Mac, read it from a file of the output:
mdimport -t -d2 dist/ios/mobile/acme/fonts/ui_normal.ttf 2>&1 | grep -A 2 name_postscriptThe command reads the file itself, so it also answers for a file that was just built, which Spotlight has not indexed yet.
The name changes when a brand changes the family of a role. To keep the app free of family names, read the name from the bundled file at run time. Add this function to the app:
import CoreText
import Foundation
/// The PostScript name of a font file of the bundle, such as "ui_normal.ttf".
func postScriptName(ofFontFile file: String) -> String? {
guard
let url = Bundle.main.url(forResource: file, withExtension: nil),
let descriptors = CTFontManagerCreateFontDescriptorsFromURL(url as CFURL)
as? [CTFontDescriptor],
let descriptor = descriptors.first
else { return nil }
return CTFontDescriptorCopyAttribute(descriptor, kCTFontNameAttribute) as? String
}Use the fonts
With the PostScript name of a role, the font loads as any custom font does. Use the function of the previous section in UIKit:
import UIKit
let label = UILabel()
if let name = postScriptName(ofFontFile: "ui_normal.ttf"),
let font = UIFont(name: name, size: 17) {
label.font = UIFontMetrics(forTextStyle: .body).scaledFont(for: font)
label.adjustsFontForContentSizeCategory = true
}Use the same name in SwiftUI:
import SwiftUI
struct Headline: View {
private let strong = postScriptName(ofFontFile: "ui_strong.ttf") ?? ""
var body: some View {
Text("Title")
.font(.custom(strong, size: 28, relativeTo: .title))
}
}Images
The build writes an image to images/ with every variant the designer exported, each under the subfolder it has in source/. The images page has the rules of the type. For a source with an image at three sizes, a logo as SVG and as PNG, and images for the light and the dark mode, the build writes:
dist/ios/<app>/<brand>/images/
├── hero_banner.png
├── hero_banner@2x.png
├── hero_banner@3x.png
├── logo/
│ ├── wordmark.png
│ └── wordmark.svg
└── onboarding/
├── welcome_dark.png
├── welcome_dark@2x.png
├── welcome_light.png
└── welcome_light@2x.pngThe iOS output has no WebP file. An image that exists only as WebP in source/ is missing from dist/ios/; export it as PNG or JPEG too.
Asset catalog
The default build does not write Assets.xcassets or a Contents.json. With the --asset-catalog option it does, and needs nothing installed for it:
npx chassis-assets build --platform ios --asset-catalogThe images move from images/ into Assets.xcassets, the files of one name into one image set, each variant in the slot of its indicator:
dist/ios/<app>/<brand>/
├── Assets.xcassets/
│ ├── Contents.json
│ ├── hero_banner.imageset/
│ │ ├── Contents.json
│ │ ├── hero_banner.png
│ │ ├── hero_banner@2x.png
│ │ └── hero_banner@3x.png
│ ├── logo/
│ │ ├── Contents.json
│ │ └── wordmark.imageset/
│ └── onboarding/
│ ├── Contents.json
│ └── welcome.imageset/
├── data/
├── fonts/
├── icons/
└── images/
└── logo/
└── wordmark.svgAdd Assets.xcassets to the project with File → Add Files to…, with the app target checked. An SVG without a PNG of its name is an image set of one file with Preserve Vector Data set. A subfolder is a folder of the catalog with Provides Namespace set, so an image of logo/ is named logo/wordmark.
A file without a place in an image set stays in images/, and the build warns about the number of them: here logo/wordmark.svg, which has a PNG of the same name.
Without the option, you make the image sets in Xcode. Drag the variants of an image into the asset catalog together, and Xcode makes one image set named after the file and puts each variant in the slot of its indicator: hero_banner.png in 1x, hero_banner@2x.png in 2x. A slot stays empty when the designer exported no variant for it, and iOS scales the nearest one.
An SVG goes into an image set of its own, with Scales set to Single Scale and Preserve Vector Data checked. An image that the output has as SVG and as PNG, such as logo/wordmark.svg beside logo/wordmark.png, needs one of the two: both would make an image set of the same name.
A name is unique within its folder only: two subfolders of images/ can hold files of one name. Keep the subfolders as folders of the catalog and check Provides Namespace on them, and an image of logo/ is logo/wordmark.
Use the images
The name of an image set is the output name without the indicator and the extension. In a catalog of --asset-catalog, an image of a subfolder has the folder before its name, as in logo/wordmark. Use the name in UIKit:
import UIKit
let imageView = UIImageView(image: UIImage(named: "hero_banner"))
imageView.contentMode = .scaleAspectFitUse the same name in SwiftUI:
import SwiftUI
struct HeroBanner: View {
var body: some View {
Image("hero_banner")
.resizable()
.scaledToFit()
}
}Dark mode
A designer who exports an image for light and for dark names the two files, as onboarding/welcome_light.png and onboarding/welcome_dark.png of the tree above. With --asset-catalog they are one image set, onboarding/welcome, with a row per appearance. Without it, make one image set, set Appearances to Any, Dark in the attributes inspector, and put the *_light variants in the Any Appearance row and the *_dark variants in the Dark row. UIImage(named:) and Image then follow the appearance of the screen with one name.
Icons
The build gives iOS the SVG, PDF and PNG files of icons/, one file per icon, such as icons/arrow_right_solid.svg. The icons page says where they come from.
Add the icons
The build does not turn an SVG into a PDF, and Xcode 12 or later needs none: an asset catalog takes an SVG as it is. With the --icon-catalog option the build writes the catalog, Icons.xcassets, with an image set per icon and a folder per subfolder of icons/, so icons/arrow_right_solid.svg is named arrow_right_solid. Without it, drag the icons the app uses from icons/ into a folder of the catalog, which makes one image set per file, then select them and set these attributes:
| Attribute | Value | Why |
|---|---|---|
| Scales | Single Scale | An SVG has no variants |
| Preserve Vector Data | Checked | The icon stays sharp at any size |
| Render As | Template Image | An icon drawn in currentcolor has no color of its own, so the tint of the view colors it |
A PDF icon takes the same attributes. A PNG icon of a brand goes into the slots of its indicators, as an image does.
Use the icons
An icon loads by the name of its image set, and takes the tint color of the view. Use it in UIKit:
import UIKit
let button = UIButton(type: .system)
button.setImage(UIImage(named: "arrow_right_solid"), for: .normal)
button.tintColor = .labelUse it in SwiftUI:
import SwiftUI
struct NextButton: View {
let action: () -> Void
var body: some View {
Button(action: action) {
Image("arrow_right_solid")
.resizable()
.frame(width: 24, height: 24)
}
.foregroundStyle(.tint)
}
}App icon
The build keeps the app icon as the bundle that Icon Composer saves, so you make no image sets and no sizes for it. A bundle source/<brand>/<app>/app-icon/app-icon.icon is written to dist/ios/<app>/<brand>/app-icon/app_icon.icon, with the same name in every brand, and the files in it keep their names. The --icon-catalog option leaves it alone: the bundle is no icon of icons/. The app icons page says what the bundle holds and how the designer saves it.
Xcode 26 or later reads a .icon bundle. Add it to the project with File → Add Files to…, with the app target checked, beside the asset catalog and not inside it. Then set App Icon under General → App Icons and Launch Screen of the target to app_icon, the name of the bundle without its extension. Xcode writes the older icon images from it when it compiles. A bundle of another name gives the setting another value: the build renames my-app.icon to my_app.icon, so the setting is my_app.
Other assets
The build copies any other folder of the app whole, in every format, with the file names in snake_case. A file source/<brand>/<app>/data/country-list.json is written to dist/ios/<app>/<brand>/data/country_list.json. A folder that only some brands hold is in the output of those brands only. The other assets page describes the type.
Add such a folder to the target as a folder reference, so that the bundle keeps the folder, and read a file by its output name:
import Foundation
let url = Bundle.main.url(
forResource: "country_list",
withExtension: "json",
subdirectory: "data"
)Brand switching
The brands of an app have the same folders, and a file that two brands both have has the same name in each, so the code of the app does not change with the brand: what changes is the folder the files come from. The build fills the output of a brand with the files of its folder in source/ and with the files of the default brand that it does not replace, so the brands share every default file and each has its own files under the same names.
The brands do not have to hold the same files. A file that only the folder of one brand holds is in the output of that brand only, and a font role that a brand holds no files for has no files in its output. An app that loads such a file builds with the brands that have it; compare the output of two brands to see which files they share:
diff <(cd dist/ios/mobile/acme && find . -type f | sort) \
<(cd dist/ios/mobile/globex && find . -type f | sort)Brand per build
An app that ships once per brand copies the folder of one brand into the project before it builds. Add a script such as scripts/sync-assets.sh to the app's repository, with the assets in the submodule vendor/assets/:
#!/bin/bash
set -euo pipefail
BRAND="${1:-acme}"
APP="${2:-mobile}"
(cd vendor/assets && npx chassis-assets build --platform ios --app "$APP" --brand "$BRAND" --clean)
rsync -a --delete "vendor/assets/dist/ios/$APP/$BRAND/" Resources/Assets/The fonts and a folder reference follow the copy as they are. An image set does not: it holds the files of the brand it was filled from. Keep one asset catalog per brand, with the same image set names, and add each to the target of its brand.
While you work on the assets and the app together, let the build follow the source: npx chassis-assets build --watch --platform ios --app mobile builds the iOS jobs of the app again on every change under source/, and the copy is then the rsync line of the script alone.
Build phase
A Run Script build phase can run the copy on each build of a target. Put it before Copy Bundle Resources, and pass it the brand from a build setting of the target, here the user-defined setting CHASSIS_BRAND:
"$SRCROOT/scripts/sync-assets.sh" "$CHASSIS_BRAND"A target runs its scripts in a sandbox when User Script Sandboxing is Yes in its build settings, as it is in a new project, and the phase then fails with Operation not permitted: the script writes to Resources/Assets/ and to the submodule. Set it to No for the target.
Xcode runs the phase with its own PATH. When it does not find npx, replace the build line of the script with the copy alone and build the assets before opening Xcode.
Brand at run time
One binary that holds several brands needs the files of each under a name of its own. Give each brand a folder in the asset catalog with Provides Namespace checked, fill it from dist/ios/<app>/<brand>/, and put the brand before the name:
import UIKit
func brandImage(_ name: String, brand: String) -> UIImage? {
UIImage(named: "\(brand)/\(name)")
}
let logo = brandImage("wordmark", brand: "globex")Continuous integration
A CI job builds the assets of one job, copies them and builds the app. The build needs Node.js, the Git LFS files of the submodule and an install of the package in it.
GitHub Actions
A matrix builds the app once per brand. Add a workflow such as this one to the app's repository, with the brands of your configuration and the project and scheme of your app:
name: iOS
on:
push:
branches: [main]
jobs:
build:
runs-on: macos-latest
strategy:
matrix:
brand: [acme, globex]
steps:
- name: Checkout
uses: actions/checkout@v7
with:
submodules: true
- name: Pull the Git LFS files of the assets
run: git -C vendor/assets lfs pull
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version-file: vendor/assets/.nvmrc
- name: Build and copy the assets
run: |
(cd vendor/assets && npm ci)
./scripts/sync-assets.sh ${{ matrix.brand }} mobile
- name: Build the app
run: |
xcodebuild -project App.xcodeproj -scheme App \
-destination 'generic/platform=iOS' \
CODE_SIGNING_ALLOWED=NO buildCODE_SIGNING_ALLOWED=NO builds the app without a certificate, which is enough to check that it builds. Without it, a runner that has no development team fails with Signing for "App" requires a development team. The xcodebuild line of this job was run on a Mac; the script with the build of the package and the workflow itself were not run.
A job that takes the archive of a release instead needs neither Node.js nor the submodule: it downloads <name>-ios-<app>-<brand>-<version>.zip and unpacks it into the project.
Fastlane
A lane takes the brand as an option and runs the same script before the build. Add it to the Fastfile; fastlane runs sh from the fastlane/ folder, hence the ../:
platform :ios do
desc "Build the app with the assets of one brand"
lane :build_brand do |options|
brand = options[:brand] || "acme"
sh("../scripts/sync-assets.sh", brand, "mobile")
build_app(scheme: "App-#{brand}")
end
endRun the lane with fastlane ios build_brand brand:globex. The lane was not run; the script it calls was.
Best practices
These practices keep the Xcode project in step with dist/ios/, so a new export or another brand needs no change in code.
- Refer to fonts by role: list
ui_normal.ttfinUIAppFontsand read the PostScript name from the file, so a brand that changes the family of a role changes no code. - Fill every slot the output has: put
@2xand@3xfiles in their slots of an image set. The build does not resize, so a missing variant is fixed by an export intosource/, not in Xcode. - Take each icon from its own file: add the icons of
icons/as single-scale SVG image sets with Preserve Vector Data and Template Image. - Keep the license with the font: copy
<role>_license.txtoffonts/along with the font files. - Build one job in CI:
npx chassis-assets build --platform ios --app <app> --brand <brand>writes onlydist/ios/<app>/<brand>/.
Avoid the habits that undo this:
- Do not rename the files in the project: the names of
dist/ios/are the contract. Rename the file insource/and build again. - Do not commit
dist/: commit the submodule pointer, or pin the version of the archive, and build or unpack the files. - Do not edit the copied files: a change to a file under
Resources/Assets/is lost at the next copy. Changesource/<brand>/<app>/instead.
Troubleshooting
Each entry gives the message or the symptom, then the cause and the fix.
Build fails on pointers
The build prints <count> source file(s) are Git LFS pointers, not files: <files>. Run `git lfs pull`, or pass --allow-lfs-pointers to copy the pointers. The clone or the submodule was made without Git LFS, so the fonts and the raster images are pointers of a few lines. Install Git LFS, run git lfs pull in the repository of the assets, and build again.
Unknown brand or app
The build prints Unknown brand "<name>". Configured: <brands>, or the same for an app or a platform. The value of the filter is not in the chassis.build block of package.json. Use a configured name, or add the brand to chassis.build.brands.
Filters select no job
The build prints The filters select no job. Check --brand, --app and --platform together. The app is not built for iOS: in the configuration of this page --platform ios --app site selects nothing, since site is a web app. Name an app that lists ios in chassis.build.apps.
Font does not appear
UIFont(name:size:) returns nil, or the text shows in the system font. Either the file is not in the bundle, or its file name is missing from UIAppFonts, or the code passes the file name where the PostScript name belongs. Check the target membership of the file, list it in Info.plist as ui_normal.ttf, with the extension, and read the PostScript name as PostScript names says.
Image is missing
UIImage(named:) returns nil for an image that is in source/. The source file is a WebP, which the iOS output leaves out, or the image set has another name than the output file, or it sits in a folder with Provides Namespace. Find the file with find dist/ios/<app>/<brand>/images -name '<name>*', and use its name without the indicator and the extension.
Image is blurry
An image looks soft on a 3x screen. The output has no @3x file for it, because the designer exported none and the build does not resize. Export the variant into source/<brand>/<app>/images/, build again, and put the file in the 3x slot.
Icon keeps one color
An icon stays black whatever the tint of the view. Its image set renders as an original image. Set Render As to Template Image in the attributes inspector.
Next steps
Continue with one of these pages:
- Fonts: the roles, the formats and the licenses of the font files.
- Images: the variants and the naming of the images.
- Icons: where the icons go in
source/and how they are named. - Other assets: any other folder of an app.
- Build system: the commands, the options and the configuration.
- Android applications and web applications: the same assets on the other platforms.