Build script that generates a source file based on Xcode assets
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


AutoAssets is a Xcode build script (written in Swift) that generates a Swift source file based on the project's assets at build time.

AutoAssets generates a source file containing enumerations of each Xcode Asset, properly name spaced in the following style:

enum IconAssets: String {
    case Music
	case Movies
    case TVShows
    func image() -> NSImage {
        return NSImage(named: self.rawValue)!

Instead of accessing image assets like this:


With the enums AutoAssets generates you can access them using proper name spacing:


For more info see my post here

By Lee Morgan. If you find this useful please let me know. I'm @leemorgan on twitter.


  1. Add a Run Script to the Target’s Build Phases

  2. Set the Shell to /usr/bin/swift

  3. Paste the AutoAssets.swift contents into the script block

AutoAssets generates a "AutoAssets.swift" file in the Source's directory at compile time.

Include the auto generated "AutoAssets.swift" in your project.

You can then access your Assets by using the following style:

let myImage = Assets.MyCustomImage.image()


The license is contained in the "License.txt" file.