Script to support easily using Xcode Asset Catalog in Swift.

Related tags

Tools Misen
Overview

Misen

Misen is a script to support using Xcode Asset Catalog in Swift.

Features

Misen scans sub-directories in the specified Asset Catalog and creates a UIImage extension file which has the following features.

  • Application-specific enum which is constructed from Asset Catalog names and UIImage object can be instantiated directly from it.
  • UIImage non-failable initializer whose argument is an enum value above.

Usage

  • Change file permissions first.
chmod +x misen.swift
  • Run the script.
./misen.swift -path PATH/TO/XCASSETS -exportPath PATH/TO/GENERATED_FILE -enumName ENUM_NAME
  • -path is a path of the asset catalog.
  • -exportPath is an output UIImage extension file path.
  • -enumName is an enum name to be generated. This is optional and ImageAsset is used as default when this parameter is not specified.

e.g.

Misen generates the file below from the asset catalog with 3 image sets below.
For reference, see the script of the sample project.

import UIKit

// MARK: - UIImage extension
extension UIImage {
    convenience init!(assetName: ImageAsset) {
        self.init(named: assetName.rawValue)
    }
}

// MARK: - ImageAsset
enum ImageAsset: String {
    case camera = "camera"
    case contact = "contact"
    case home = "home"

    var image: UIImage {
        return UIImage(named: self.rawValue)!
    }
}
  • In your code, you can instantiate images in Asset Catalog as follows.
class ViewController: UIViewController {

    @IBOutlet weak var cameraImageView: UIImageView! {
        didSet {
            // Instantiate UIImage directly from ImageAsset enum
            cameraImageView.image = ImageAsset.camera.image
        }
    }

    @IBOutlet weak var contactImageView: UIImageView! {
        didSet {
            contactImageView.image = ImageAsset.contact.image
        }
    }

    @IBOutlet weak var homeImageView: UIImageView! {
        didSet {
            // Instantiate UIImage with UIImage extension
            homeImageView.image = UIImage(assetName: .home)
        }
    }
    ...
}

Requirements

  • Xcode 8.0
  • Swift 3.0

Release Notes

See Releases.

License

Misen is released under the MIT license. See LICENSE for details.

You might also like...
An iOS app decrypter, full static using fouldecrypt.
An iOS app decrypter, full static using fouldecrypt.

Iridium An iOS app decrypter, full static using fouldecrypt. Supporting iOS 13+ Note We have built everything into the package, you can install and fl

Swift CLI for strong-typing images, colors, storyboards, fonts and localizations

Shark Shark is a Swift command line tool that generates type safe enums for your images, colors, storyboards, fonts and localizations. Because Shark r

Strong typed, autocompleted resources like images, fonts and segues in Swift projects
Strong typed, autocompleted resources like images, fonts and segues in Swift projects

R.swift Get strong typed, autocompleted resources like images, fonts and segues in Swift projects Why use this? It makes your code that uses resources

SwiftGen is a tool to automatically generate Swift code for resources of your projects
SwiftGen is a tool to automatically generate Swift code for resources of your projects

SwiftGen SwiftGen is a tool to automatically generate Swift code for resources of your projects (like images, localised strings, etc), to make them ty

Soulful docs for Swift & Objective-C
Soulful docs for Swift & Objective-C

jazzy is a command-line utility that generates documentation for Swift or Objective-C About Both Swift and Objective-C projects are supported. Instead

Laurine - Localization code generator written in Swift. Sweet!
Laurine - Localization code generator written in Swift. Sweet!

Author's note: Thanks everyone for making Laurine the TOP trending Swift repository in the world - this is amazing and very heart-warming! But this is

Swift autocompleter for Sublime Text, via the adorable SourceKitten framework
Swift autocompleter for Sublime Text, via the adorable SourceKitten framework

SwiftKitten SwiftKitten is a Swift autocompleter for Sublime Text, via the adorable SourceKitten framework. Faster than XCode ! This package is new an

Script to support easily using Xcode Asset Catalog in Swift.
Script to support easily using Xcode Asset Catalog in Swift.

Misen Misen is a script to support using Xcode Asset Catalog in Swift. Features Misen scans sub-directories in the specified Asset Catalog and creates

Script to support easily using Xcode Asset Catalog in Swift.
Script to support easily using Xcode Asset Catalog in Swift.

Misen Misen is a script to support using Xcode Asset Catalog in Swift. Features Misen scans sub-directories in the specified Asset Catalog and creates

🔥 🔥 🔥Support for ORM operation,Customize the PQL syntax for quick queries,Support dynamic query,Secure thread protection mechanism,Support native operation,Support for XML configuration operations,Support compression, backup, porting MySQL, SQL Server operation,Support transaction operations.

🔥 🔥 🔥Support for ORM operation,Customize the PQL syntax for quick queries,Support dynamic query,Secure thread protection mechanism,Support native operation,Support for XML configuration operations,Support compression, backup, porting MySQL, SQL Server operation,Support transaction operations.

An executable that can be called from a Run Script Build Phase that makes comments such as // TODO: or // SERIOUS: appear in Xcode's Issue Navigator giving them project-wide visibility.

XcodeIssueGenerator An executable that can be called from a Run Script Build Phase that makes comments such as // TODO: or // SERIOUS: appear in Xcode

Create an easy to peek SwiftUI View to showcase your own data, catalog, images, or anything you'd like.
Create an easy to peek SwiftUI View to showcase your own data, catalog, images, or anything you'd like.

Create an easy to peek SwiftUI View to showcase your own data, catalog, images, or anything you'd like.

HOMEPOK - Catalog of Ukrainian vehicle plates (App Store)
HOMEPOK - Catalog of Ukrainian vehicle plates (App Store)

HOMEPOK - Catalog of Ukrainian vehicle plates, available on App Store Description Screenshots License Contact Description: The main goal of the iPhone

Reading List is an iOS app for iPhone and iPad which helps users track and catalog the books they read
Reading List is an iOS app for iPhone and iPad which helps users track and catalog the books they read

Reading List Reading List is an iOS app for iPhone and iPad which helps users track and catalog the books they read. Reading List v2 As of version 2.0

Simple implementation of asset management app UI using swiftUI
Simple implementation of asset management app UI using swiftUI

MyAssets (자산관리 앱 만들기) swiftUI를 이용하여 자산관리 앱 UI를 간략하게 구현 (swiftUI를 익히기 위함) 초기 화면 1. Tab bar 구현 자산, 추천, 알람, 설정 탭 구현 2. Navigation bar 구현 1) leading에 titl

Combine SnapshotTesting images into a single asset
Combine SnapshotTesting images into a single asset

An extension to SnapshotTesting which allows you to create images combining the output of multiple snapshot strategies, assuming they all output to UIImage.

Apple Asset Cache (Content Cache) Tools

AssetCacheTool A library and tool for interacting with both the local and remote asset caches. This is based on research I did a few years ago on the

Enables easy, convenient asynchronous asset loading in RealityKit for many different kinds of assets.

RealityKit Asset Loading Discussion This package includes classes and examples that enable easy, convenient asynchronous asset loading in RealityKit f

A library and tool for interacting with both the local and remote asset caches.

Asset Cache Tool A library and tool for interacting with both the local and remote asset caches. This is based on research I did a few years ago on th

Comments
  • Swift2.0

    Swift2.0

    This PR updates the project and its code to Swift2 syntax to use in the Xcode 7,

    This has been tested in:

    • [x] Xcode 7 beta 6
    • [ ] Xcode 7 RC
    • [x] Xcode 7 GM
    opened by tasanobu 0
  • xcrun --sdk macosx

    xcrun --sdk macosx

    After I added a Run Script Phase that executed misen.swif in an iOS application project, my build began failing due to several shell script Invocation errors and warnings.

    The most relevant was:

    using sysroot for 'iPhoneSimulator' but targeting 'MacOSX'

    Which made me think that you must specify that you want to use the macosx SDK in order to execute misen.swift.

    opened by hectr 0
Releases(0.4.0)
Owner
Kazunobu Tasaka
Kazunobu Tasaka
An Xcode plug-in to format your code using SwiftLint.

SwiftLintXcode An Xcode plug-in to format your code using SwiftLint. Runs swiftlint autocorrect --path CURRENT_FILE before *.swift file is saved. IMPO

Yuya Tanaka 348 Sep 18, 2022
swiftenv allows you to easily install, and switch between multiple versions of Swift.

Swift Version Manager swiftenv allows you to easily install, and switch between multiple versions of Swift. This project was heavily inspired by pyenv

Kyle Fuller 1.9k Dec 27, 2022
An Xcode Plugin to convert Objective-C to Swift

XCSwiftr Convert Objective-C code into Swift from within Xcode. This plugin uses the Java applet of objc2swift to do the conversion. Noticed that the

Ignacio Romero Zurbuchen 338 Nov 29, 2022
Automatically build and rebuild Xcode image catalogs for app icons, universal images, and more

Better asset workflow for iOS developers. Generate Xcode image catalogs for iOS / OSX app icons, universal images, and more.

Dotan J. Nahum 822 Dec 21, 2022
Xcode storyboards diff and merge tool.

StoryboardMerge Storyboard diff and merge tool which: compares and merges two storyboard files, provides an automatic merge-facility, The storyboardin

null 238 Sep 12, 2022
Xcode .appiconset generator for Adobe Illustrator.

Creating AppIcon sets from Adobe Illustrator This repo is rewrited from original repo https://github.com/CaryChamplin/CreatingIconsFromAI. Just genera

gitmerge 73 Nov 9, 2020
A git plugin for real-world xcode versioning workflow.

git-xcp The most simplest, safe, and fully automatic git plugin for versioning workflow of real-world xcode projects. Current working or draft content

gitmerge 11 Dec 29, 2019
Xcode-compatible build tool.

xcbuild xcbuild is an Xcode-compatible build tool with the goal of providing faster builds, better documentation of the build process and running on m

Meta Archive 2k Dec 11, 2022
This repository contains rules for Bazel that can be used to generate Xcode projects

rules_xcodeproj This repository contains rules for Bazel that can be used to generate Xcode projects. If you run into any problems with these rules, p

BuildBuddy 233 Dec 28, 2022
An iOS app decrypter, full static using fouldecrypt.

Iridium An iOS app decrypter, full static using fouldecrypt. Supporting iOS 13+ Note We have built everything into the package, you can install and fl

Lakr Aream 234 Jan 9, 2023