Script to support easily using Xcode Asset Catalog in Swift.

Related tags

Image 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...
You can use blur effect and it's animation easily to call only two methods.

SABlurImageView You can use blur effect and it's animation easily to call only two methods. ManiacDev.com referred. https://maniacdev.com/2015/04/open

Gifu adds protocol-based, performance-aware animated GIF support to UIKit.
Gifu adds protocol-based, performance-aware animated GIF support to UIKit.

Gifu adds protocol-based, performance-aware animated GIF support to UIKit. (It's also a prefecture in Japan). Install Swift Package Manager Add the fo

add text(multiple line support) to imageView, edit, rotate or resize them as you want, then render the text on image
add text(multiple line support) to imageView, edit, rotate or resize them as you want, then render the text on image

StickerTextView is an subclass of UIImageView. You can add multiple text to it, edit, rotate, resize the text as you want with one finger, then render the text on Image.

 SwiftGif - A small UIImage extension with gif support.
SwiftGif - A small UIImage extension with gif support.

SwiftGif - A small UIImage extension with gif support.

Image viewer (or Lightbox) with support for local and remote videos and images
Image viewer (or Lightbox) with support for local and remote videos and images

Table of Contents Features Focus Browse Rotation Zoom tvOS Setup Installation License Author Features Focus Select an image to enter into lightbox mod

Asynchronous image downloader with cache support as a UIImageView category
Asynchronous image downloader with cache support as a UIImageView category

This library provides an async image downloader with cache support. For convenience, we added categories for UI elements like UIImageView, UIButton, M

Photo Browser / Viewer inspired by Facebook's and Tweetbot's with ARC support, swipe-to-dismiss, image progress and more
Photo Browser / Viewer inspired by Facebook's and Tweetbot's with ARC support, swipe-to-dismiss, image progress and more

IDMPhotoBrowser IDMPhotoBrowser is a new implementation based on MWPhotoBrowser. We've added both user experience and technical features inspired by F

An image cropper / photo cropper for iOS like in the Contacts app with support for landscape orientation.
An image cropper / photo cropper for iOS like in the Contacts app with support for landscape orientation.

RSKImageCropper An image cropper for iOS like in the Contacts app with support for landscape orientation. Installation RSKImageCropper requires iOS 9.

A tool support convert image gif to gif3d
A tool support convert image gif to gif3d

Trick convert gif to gif3d using Swift Features Simple way to convert gif to gif3d Change background Change size eraser tool How to work Add a layer w

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
Easily Manage Graphics in Xcode Projects

Introduction Challenges Managing Graphic Assets Manually Create Multiple Sizes Store Generated Image Files What If You Had... Care-Free Graphic Manage

BrightDigit 116 Nov 14, 2022
Xcode-streamdeck-plugin - A Stream Deck plugin for Xcode

Stream Deck Xcode Plugin This repository contains a Stream Deck plugin to add so

Daniel Kennett 77 Dec 27, 2022
Xcode plugin that brings โ‡งโŒ˜T from AppCode over to Xcode

Aviator An Xcode Plugin that brings โ‡งโŒ˜T over to Xcode This minimal plugin allows you to use the key combo โ‡งโŒ˜T to toggle between source and test files.

Mark Sands 29 Aug 18, 2018
In-app screen recording using ReplayKit in iOS. Written in Swift 5 on Xcode 12.3

In-App-ScreenRecording-iOS In-app screen recording using ReplayKit in iOS. Written in Swift 5 on Xcode 12.3 Features: Recording application screen onl

Ahmed Abdelkarim 4 Dec 23, 2022
Agrume - ๐Ÿ‹ An iOS image viewer written in Swift with support for multiple images.

Agrume An iOS image viewer written in Swift with support for multiple images. Requirements Swift 5.0 iOS 9.0+ Xcode 10.2+ Installation Use Swift Packa

Jan Gorman 601 Dec 26, 2022
High-performance animated GIF support for iOS in Swift

Gifu adds protocol-based, performance-aware animated GIF support to UIKit. (It's also a prefecture in Japan). Install Swift Package Manager Add the fo

Reda Lemeden 2.6k Jun 21, 2021
A better way to operate QR Code in Swift, support iOS, macOS, watchOS and tvOS.

EFQRCode is a lightweight, pure-Swift library for generating stylized QRCode images with watermark or icon, and for recognizing QRCode from images, in

EFPrefix 4.3k Jan 2, 2023
FlexibleImage is implemented with the hope that anyone could easily develop an app that provides features such as Camera Filter and Theme.

FlexibleImage is implemented with the hope that anyone could easily develop an app that provides features such as Camera Filter and Theme. When you wr

Jungwon An 815 Dec 30, 2022
Easily display images, animations, badges and alerts to your macOS application's dock icon

DSFDockTile Easily display images, animations, badges and alerts to your macOS application's dock icon. Why? I was inspired by Neil Sardesai after he

Darren Ford 45 Dec 2, 2022
Shows your photo library grouped by events, to easily export them to your computer

Groupir Shows your photo library grouped by events, to easily export them to your computer Features Currently supported features: reading your photo l

Stanislas Chevallier 0 Dec 15, 2021