Swiftpack.co - Package - endocrimes/AssetGen

AssetGen

AssetGen automatically creates structs and enums for your Asset Catalogs.

It supports multiple catalogs and folders inside them.

Usage

Usage: $ /path/to/AssetGen [--input /path/to/project/root] [--output /path/to/Assets.swift]

You get something like this:

// Generated by AssetGen.swift
import UIKit
protocol AssetGenImageProtocol: RawRepresentable {
    var image: UIImage { get }
}

extension AssetGenImageProtocol where RawValue == String {
    var image: UIImage {
        return UIImage(named: rawValue)!
    }
}

struct ImageResources {
    enum AnotherAssetCatalog: String, AssetGenImageProtocol {
        case MuteSelected = "mute selected"
    }
    enum MyAssetCatalog: String, AssetGenImageProtocol {
        case SomeAsset = "some_asset"
        enum AFolder: String, AssetGenImageProtocol {
            case LinkIcon = "link icon"
        }
    }
}

That can then be used like this:

let myImage: UIImage = ImageResources.MyAssetCatalog.SomeAsset.image

Building

To build AssetGen, you need Swift, and it's Package Manager installed.

When you have those, it can be built with:

$ swift build

And ran from within the .build directory.

Installation

$ git clone https://github.com/endocrimes/AssetGen.git
$ swift build --configuration release
$ sudo cp .build/release/AssetGen /usr/local/bin/AssetGen

Github

link
Stars: 3

Used By

Total: 0

Releases

Initial Release - 2015-12-09 13:05:47