Skip to content
This repository has been archived by the owner on Jun 29, 2022. It is now read-only.
/ TypedCatalog Public archive

Code generator for strong-typed asset catalogs

License

Notifications You must be signed in to change notification settings

seatcode/TypedCatalog

Repository files navigation

TypedCatalog

What?

TypedCatalog is a CLI to support using Xcode Asset Catalog in Swift.

TypedCatalog development started as a fork of Misen.

Why?

It makes your assets code:

  • compile time checked,
  • strong typed,
  • autocompletable by Xcode.

How?

Installation

There are several methods to install Unstringify:

Usage

Usage: TypedCatalog \
    -path path_to_asset_catalog \
    -exportPath output_path \
    -bundleName bundle_asset_catalog_belongs_to \
    -bundleAssociatedClass some_class_inside_bundle \
    -enumName generated_enum_name

Example

Given a project where all the asset catalogs are contained in a development pod called Assets.

  • Place your asset catalogs in the directory Modules/Assets/Resources/.

  • Add the following to your Modules/Assets/Assets.podspec file:

s.resource_bundles = {
    'CommonsUI' => ['Resources/*.xcassets']
}

s.script_phase = { :name => 'Generate Images Enums', :script => 'eval "${SRCROOT}/../Modules/Assets/Scripts/generate_images_enums.sh Assets ${SRCROOT}/../Modules/Assets/Resources ${SRCROOT}/../Modules/Assets/Sources"', :execution_position => :before_compile }

s.prepare_command = <<-CMD
Scripts/generate_images_enums.sh 'Resources' 'Classes/Images'
CMD

s.source_files = 'Sources/**/*'
  • Copy generate_images_enums.sh to Modules/Assets/Scripts/.

  • Add Assets dependency to podspecs of all modules that will use the assets:

s.dependency 'Assets'
  • Add the Assets module to the application's Podfile:
pod 'Assets', :path => './Modules/Assets'

License

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

Alternatives