AutoAssets
Build script that generates a source file based on Xcode assets
Install / Use
/learn @leemorgan/AutoAssetsREADME
AutoAssets
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:
UIImage(named:"someImage")
With the enums AutoAssets generates you can access them using proper name spacing:
IconAssets.Music.image()
<br>
For more info see my post here
By Lee Morgan. If you find this useful please let me know. I'm @leemorgan on twitter.
Usage
-
Add a Run Script to the Target’s Build Phases
-
Set the Shell to
/usr/bin/swift -
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()
License
The license is contained in the "License.txt" file.
Related Skills
node-connect
350.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
