All Projects → inquisitiveSoft → Xcassetpacker

inquisitiveSoft / Xcassetpacker

Licence: other
A command line tool for converting a folder of images into an .xcasset package for Xcode

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Xcassetpacker

Swiftcolorgen
A tool that generate code for Swift projects, designed to improve the maintainability of UIColors
Stars: ✭ 152 (+1.33%)
Mutual labels:  cli, xcode, code-generation, code-generator
evon
Fast and versatile event dispatcher code generator for Golang
Stars: ✭ 15 (-90%)
Mutual labels:  code-generator, code-generation, codegen
EasyEE-Auto
EasyEE 自动化代码生成器。EasyEE Automated code generator.
Stars: ✭ 39 (-74%)
Mutual labels:  code-generator, code-generation, codegen
R.objc
Get autocompleted resources like images, localized strings and storyboards in ObjC projects
Stars: ✭ 92 (-38.67%)
Mutual labels:  xcode, code-generator
Spellchecker
SpellChecker for Xcode
Stars: ✭ 79 (-47.33%)
Mutual labels:  cli, xcode
Imscript
a collection of small and standalone utilities for image processing, written in C
Stars: ✭ 86 (-42.67%)
Mutual labels:  cli, images
Scala Db Codegen
Scala code/boilerplate generator from a db schema
Stars: ✭ 49 (-67.33%)
Mutual labels:  code-generation, code-generator
Swiftplaygroundscli
Easily generate Swift Playgrounds from your command line 👨‍💻
Stars: ✭ 103 (-31.33%)
Mutual labels:  cli, xcode
Goreuse
Generic Code for Go
Stars: ✭ 93 (-38%)
Mutual labels:  code-generation, code-generator
Appicon
AppIcon generates *.appiconset contains each resolution image for iOS
Stars: ✭ 1,454 (+869.33%)
Mutual labels:  cli, xcode
Toolkit
Collection of useful patterns
Stars: ✭ 137 (-8.67%)
Mutual labels:  code-generation, code-generator
Aarkay Archived
AarKay is a language independent code generation framework. This project has been deprecated and is no longer maintained.
Stars: ✭ 69 (-54%)
Mutual labels:  code-generator, codegen
Mid
mid is a generic domain-specific language for generating code and documentation
Stars: ✭ 68 (-54.67%)
Mutual labels:  code-generation, code-generator
Spider
A small dart library to generate Assets dart code from assets folder.
Stars: ✭ 90 (-40%)
Mutual labels:  cli, code-generation
R.swift
Strong typed, autocompleted resources like images, fonts and segues in Swift projects
Stars: ✭ 8,419 (+5512.67%)
Mutual labels:  xcode, code-generator
Geco
Simple code generator based on a console project, running on .Net core and using C# interpolated strings
Stars: ✭ 97 (-35.33%)
Mutual labels:  code-generation, code-generator
Natrium
A pre-build (Swift) script to alter your Xcode project at pre-build-time per environment, build configuration and target.
Stars: ✭ 131 (-12.67%)
Mutual labels:  cli, xcode
Swiftplate
Easily generate cross platform Swift framework projects from the command line
Stars: ✭ 1,746 (+1064%)
Mutual labels:  cli, xcode
Sequelize Ui
Browser-based GUI for previewing and generating Sequelize project files.
Stars: ✭ 142 (-5.33%)
Mutual labels:  code-generator, codegen
Dogen
Reference implementation of the MASD Code Generator.
Stars: ✭ 44 (-70.67%)
Mutual labels:  code-generation, code-generator

XCAssetPacker

XCAssetPacker is a command line tool to create an Xcode .xcasset package from a folder of images.

Installation

The easiest way to get up and running is to use homebrew: brew install inquisitiveSoft/tools/XCAssetPacker

Alternatively, it's very easy to download and build from source using Xcode. All dependencies are included directly in the project.

Usage

I recommend calling xcassetpacker with the --force flag and treating the .xcassets and Swift output file as purely machine-generated.

xcassetpacker
	--input "Images/Source"
	--output "Resources/App.xcassets"
	--config "Images/Source/Main App Images Configuration.json"
	--swift "Code/Images.swift"
	--force

Command Line Options

-i, --input: Path to the input folder. -c, --config: The location of a json configuration file. If none is specified then uses sensible defaults. -o, --output: Path to the output file or folder. If a folder is given then an Assets.xcassets package will be created inside it. --swift: Path to the output swift file or folder. If a folder is given then an Images.swift package will be created inside it. -f, --force: Overwrite any existing .xcassets package or Swift file. -h, --help: Prints a help message.

You can set the target for generated Swift using: --iOS, --mac or --watch. By default it will generate iOS code.

Image Naming Conventions

There are a number of image naming conventions which will be auto-detected.

  • Scale is determined using a trailing @1x, @2x or @3x.

  • Image type will also be detected using the following suffixes:

Suffix Detected Image Type
-38 Image targeting the smaller Apple Watch
-42 Image targeting the larger Apple Watch
-20 Notification icon
-29 Settings icon
-40 Spotlight icon
-60 iPhone App icon
-76 iPad App icon
-83.5 iPad Pro App icon
  • In addition AppIcon is recognized as a standard icon name. App icons are stored slightly differently internally and will be marked as prerendered by default. For example an image named [email protected] would be detected as the spotlight icon for the Plus sized iPhone.

Configuration.json

XCAssetPacker has sensible defaults, so you can get started straight away, but you can also configure it using a JSON file. The most common uses are for filtering which images are included, and to set image properties such as target device or rendering intent of images.


Skip images that match the given regex patterns:

"skip-images" : {
	"patterns" : ["Watch App .*", "Bed.*"]
}

Determine which images to include. Defaults to png only:

"valid-image-extensions" : ["png", "jpeg", "jpg", "tiff"]

Apply a dictionary of properties to every image:

"base" : {
	"template-rendering-intent" : "template"
}

Apply properties based on the target device:

"devices" : [
	{
		"device-type" : "watch",
		"properties" : {
			"template-rendering-intent" : "template"
		}
	}
]

By default, images following the AppIcon-{size}.png naming convention will be treated as prerendered app icons and won't be exposed to Swift, or you can customize the app-icon properties:

"app-icon" : {
	"pattern" : "Custom App Icon Name.*",
	"prerendered" : false		/* Defaults to true */
}

Apply a dictionary of properties to images matched by the given patterns:

"custom" : [
	{
		"patterns" : [".*Preview.*", "SleepDuration.*", "WakeTime.*"],
		"properties" : {
			"template-rendering-intent" : "original"
		}
	}
]

template-rendering-intent is a property that iOS uses to determine whether an image has a tintColor applied. Valid properties are rendering (tinted) or original (not-tinted). Not supplying a value is equivalent to the 'Default' option in Xcode's UI.

A good starting point might be the Example Configuration.json.

Credits

Uses Ben Gollmer's nifty CommandLine framework for parsing CLI input.

License

Open sourced under the Apache Version 2.0 License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].