Automatically build and rebuild Xcode image catalogs for app icons, universal images, and more

Related tags

Tools blade
Overview

Blade Build Status
Blade

Automatically build and rebuild Xcode image catalogs for app icons, universal images, and more.

  • Use in existing projects to generate image catalogs with no extra work. Blade will automagically refresh your image catalogs based on given master images.
  • Use templates of image catalogs to generate new catalogs (see templates).

See blade-sample for a preconfigured project.

Why?

Because most of the time your image catalogs are the same image, resized to various sizes.

Here is how people solve this usually:

The problem with these solutions is:

  • Some times the various slices are not up to date with Xcode (new devices, new sizes)
  • It Almost always require extra work from you (placing each image manually in the catalog, fixing mismatches etc.)
  • You can't control the quality of the resize
  • You can't integrate the tooling into your build workflow or CI

Blade is an open source tool which will replace the PSD template and/or online services for you, and has a goal to satisfy the above requirements in the best way possible.

Quick start

You have 2 ways to install:

Homebrew

Using Homebrew:

 $ brew tap jondot/tap
 $ brew install blade

Release

Download one of the binaries in releases, and put in your PATH or just include in each Xcode project's root.

This should be a typical run of blade:

Use a Bladefile

Here's how a project setup with a Bladefile feels like (more in the Blade Sample repo):

The best way to use Blade, is to set up a local Bladefile for your entire project. Within it, specify all of your resources. Blade will pick it up automatically.

See blade-sample for a preconfigured project.

$ blade --init
Wrote Bladefile.

Here is how your Bladefile would look like:

blades:
  - source: [email protected]
    mount: foobar/Assets.xcassets/AppIcon.appiconset
  - source: Spaceship_1024.png
    mount: foobar/Assets.xcassets/Spaceship.imageset

It was made for this project structure:

foobar
├── Bladefile
├── images
│   ├── [email protected]
│   └── Spaceship_1024.png
├── foobar
│   ├── AppDelegate.swift
│   ├── Assets.xcassets
│   │   ├── AppIcon.appiconset
│   │   │   └── Contents.json
│   │   └── Spaceship.imageset
│   │       ├── Contents.json

Then use Blade (use --verbose if you want logs) within the same folder where your Bladefile lives:

$ blade --verbose
INFO[0000] Found a local Bladefile.
INFO[0000] Bladefile contains 2 blade defs.
...

And it will generate all of the images needed within each image catalog.

To make this happen before each build see how to run a script while building a product

Use directly

$ blade [email protected] --template=templates/watch.json --out=out/watch --catalog

Here's what we did:

  • Use a source image (--source)
  • Make a brand new image catalog (--catalog), from a template (templates/watch.json)
  • Put everything in out/watch
$ blade -s [email protected] -t existing.imageset -o existing.imageset

Here's what we did:

  • Use a source image (-s)
  • Point to an existing image catalog (-t)
  • Output to that same existing image catalog (-o)
  • In other words, Blade will refresh the images in this catalog

How does it work?

Blade parses the same Xcode image catalog configuration file as its own configuration source - no new concept introduced. This allows it to be future-proof with Xcode updates for new image sizes and catalog types.

Supported workflows:

  • Prototyping ad-hoc, while prototyping projects
  • Development build with Build Steps, transforming all of your source image assets to image catalogs
  • CI in your CI servers, either on OSX or Linux (though Linux can't compile code in this case, you can still use it to do image processing)

Supported resize algorithms (-i or --interpolation flag):

See here for live samples.

Hacking on Blade

Pull requests are happily accepted.

Here's what you should know if you want to improve Blade:

  • Your workflow starting point is the Makefile. There you should see how to setup the development tooling, run builds, tests and coverage.
  • The architecture splits out the runner from the converter, so that we could swap to other, faster, converters (vips) if needed.
  • The other concerns are the Contents.json (contents.go) parsing and dimension (dimensions.go) computation logic.
  • Finally, you're left with the Bladefile (bladefile.go) and CLI (main.go) logic to handle.

Also, check out fixtures for quick image catalog configuration to work with.

Here is a typical flow:

  1. Clone project
  2. Branch off for your changes
  3. Edit code
  4. Test your changes, submit PR
  5. (release) make bump
  6. (release) make release
  7. (release) use hub to upload release binaries
  8. (release) make brew_sha ver=
  9. (release) update jondot/homebrew-tap version and sha to point to new binary

(* 'release' flows are done by core committers)

Contributing

Fork, implement, add tests, pull request, get my everlasting thanks and a respectable place here :).

Copyright

Copyright (c) 2015 Dotan Nahum @jondot. See MIT-LICENSE for further details.

Comments
  • @2x or @3x

    @2x or @3x

    I really enjoy blade. Really like it because it's easy to create a build phase and have everything run automatically, never worry about that stuff anymore.

    Though, I do have a question. When I supply an @3x image, this is what my result looks like: screenshot 2015-10-07 10 17 29 As you can see, it seems that the @3x image is used as an @2x image. This can be a misunderstanding on my side, but I would expect that I have to supply the biggest possible image.

    Also, I learned that it's best practice to design @1x images using vector formats. When slicing you just slice everything and than resize your canvas @2x and @3x to make sure you don't get "half pixels" with the @1x images. I know it has been suggested here, but it might be a useful addition to support one (or more vector formats). Those vector files would be the @1x images, and then automate the steps described above.

    bug 
    opened by RebelDesigner 22
  • AppIcon for watchOS

    AppIcon for watchOS

    In Apple Watch, size of the icon of 42mm for NotificationCenter is "27.5x27.5":

        {
          "size" : "27.5x27.5",
          "idiom" : "watch",
          "filename" : "[email protected]",
          "scale" : "2x",
          "role" : "notificationCenter",
          "subtype" : "42mm"
       },
    

    GetSize, therefore, should return floating point.

    opened by safx 2
  • Add support for custom output size

    Add support for custom output size

    It would be incredibly useful to be able to set the output resolution in points for an image, because you could store the massive full resolution files and only export low resolution images, which gives you the flexibility of later changing the export resolution as needed.

    opened by thecodewarrior 0
  • Blade vNext

    Blade vNext

    Hi all!

    I've been planning to make Blade more powerful for a long while. Since interest has been growing tremendously for this tool recently, I think that is enough motivation to kick off the next iteration of Blade. I've been requested many times to also have Android support (in addition to updating Blade to recent Apple products), and that is something I plan to have.

    You can help! Please comment below of what features you'd like to have the most.

    @eralpkaraduman @Dschee @huafeng1992 @ntnmrndn @martinprot @emilwojtaszek please feel free to chime in 🥇

    opened by jondot 6
  • iPhone and iPad Notification have not automatically generated

    iPhone and iPad Notification have not automatically generated

    Xcode version 8.3.3,OS 10.12.6

    I use the following command: "blade -s icon.png -o AppIcon.appiconset -c" AppIcon.appiconset is a empty directory. A new Contents.json file and all size icons are automatically generated in AppIcon.appiconset directory . That's greate. But the iPhone and iPad Notification sizes are still missing.

    Then,I use the following command: "blade -s icon.png -o AppIcon.appiconset -c -t AppIcon.appiconset/Contents.json" Nothing happened.

    But I open the Xcode project, which uses the AppIcon.appiconset above,use the following command again. "blade -s icon.png -o AppIcon.appiconset -c -t AppIcon.appiconset/Contents.json"

    The iPhone Notification and iPad Notification are both automatically generated.

    Is there any way to generate all icons (especially notification) without opening Xcode project?

    opened by l260205354 0
  • blade fatal error: fault [signal 0xb addr=0xf3201307c33 pc=0x13f732]

    blade fatal error: fault [signal 0xb addr=0xf3201307c33 pc=0x13f732]

    Hello, I have a problem with blade. I can't find the reason. If you know the question, please reply to me. Thank you How can I get your failure status and terminate shell?

    error image:

    img

    opened by huafeng1992 6
  • Support iMessage Extension & Sticker Pack icons

    Support iMessage Extension & Sticker Pack icons

    Let's support icon sizes for iMessage iMessage extensions & sticker packs.

    Guidelines

    Discussed under iMessage App and Sticker Pack Icons https://developer.apple.com/ios/human-interface-guidelines/extensions/messaging/

    By the time I'm writing this, it required variations in sizes:

    • 1024px by 768px
    • 120px by 90px
    • 64px by 48px
    • 180px by 135px
    • 96px by 72px
    • 58px by 58px
    • 148px by 110px
    • 87px by 87px
    • 54px by 40px
    • 134px by 100px
    • 81px by 60px
    opened by eralpkaraduman 2
  • Incremental builds

    Incremental builds

    When blade is integrated as a build script to automatically be run on each build then build times can become quite long because blade is generating all images – even if nothing has changed. Therefore it would be great if blade could detect when it has to rebuild images and otherwise just keep things as is and skip images that didn't change.

    I think in order to achieve this there are several possibilities. The easiest could be that blade simply checks the last change dates of the source file and the destination file and compares those. If the destination file was last changed after the source file was changed then it could skip rebuilding the image, otherwise it would behave like now.

    Alternatively blade could also generate a file (something like Bladefile.lock) which lists the date the source images were last built and check if that date is after the source images last change date and the Bladefiles last change date then it would skip the image if both cases were given.

    If implemented there should also be a possibility to force rebuilding all images, something like blade --no-skip-unchanged is what I'm thinking of. We could also make it opt-in like so: blade --skip-unchanged.

    What do you think? Unfortunately I can't do these changes myself since I don't speak Go (yet).

    opened by Jeehut 2
Releases(v0.0.9)
Owner
Dotan J. Nahum
Dotan J. Nahum
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

Wunderman Thompson Apps 143 Oct 11, 2022
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

null 8.3k Jan 5, 2023
automatically delete the current project's DerivedData directories

Feature automatically delete the current project's DerivedData directories Usage It will be automatically deleted DerivedData when you run the clean I

Toshihiro Morimoto 242 Dec 16, 2022
Build native iOS, Android, and Web apps with Capacitor and Remix.run 💿

This repository holds production ready Capacitor templates for building native mobile applications using Remix. Using Capacitor, you can quickly build out a native mobile application for iOS and Android using web technology, such as Remix.

Ionic 70 Dec 30, 2022
AVXCAssets Generator takes path for your assets images and creates appiconset and imageset for you in just one click

AVXCAssets Generator Often while developing an app, We ran into a condition when we need to scale images to each and every aspect ratios for icons and

Angel Vasa 339 Dec 6, 2022
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

Kaan Dedeoglu 377 Dec 1, 2022
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

Mathijs Kadijk 8.9k Jan 6, 2023
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
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

Kazunobu Tasaka 123 Jun 29, 2022
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
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
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
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
A super simple retina (2x, 3x) image converter.

Retini A super fast and simple retina (@2x, @3x) image converter. How to use? You can download the prebuilt application from the releases, or just dow

Erik Terwan 200 Dec 21, 2022
Shows your current framerate (fps) in the status bar of your iOS app

WatchdogInspector Shows your current framerate (fps) in the status bar of your iOS app Be a good citizen! Don't block your main thread! WatchdogInspec

Christian Menschel 510 Nov 24, 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
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 226 Dec 24, 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