Member-only story
How To Automate Asset Management in Your iOS Apps
Facilitate colors, images, and localizations using R.swift
In this tutorial, we will learn how and why we should use asset automation in our iOS apps. We will do it by using a popular open source library, R.swift. By the time you finish the article, you will have learned how to automate:
- Images
- Colors
- Localizations
Without further ado, let’s get started.
Let’s Start
We start with an empty project, shown below:

Our first step is to add R.swift to the project. We are going to install it via CocoaPods by running pod install
after adding this line to the Podfile:
pod ‘R.swift’
Great, now that R.swift is installed, we need to adjust the targets’ Build Phases. Start with adding a new run script phase as follows:

After we create the new “Run Script,” we move it above the “Compile Sources,” as shown below:

The reason for is that the library will generate a R.generated.swift
file, which will have all the properties that reference the assets used in our app. We want it generated before the app compiles all the files.
The next step is to define the actual script. Add “$PODS_ROOT/R.swift/rswift” generate “$SRCROOT/R.generated.swift”
as follows:

Also, uncheck “Based on dependency analysis” to make the script run each build: