Skip to content

ashleycameron/bian

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bian

A small macOS command line utility for managing alternative iOS icons in Xcode projects.

Given a directory of icon images, Bian will automatically update your Info.plist with alternative icon entries and optionally autogenerate an associated Swift enum and .xcassets resource.

Minimum requirements

  • macOS 10.13 and higher
  • Xcode 11.0 and higher

Arguments

  • --icons-dir - Directory of icon image files to parse (e.g. /AwesomeApp/AltIcons).
  • --info-plist - Path to the Info.plist for your iOS app (e.g. /AwesomeApp/Info.plist).
  • --swift-output - (Optional) Output path for autogenerated Swift enum (e.g. /AwesomeApp/AltIcons.swift).
  • --xcassets-output - (Optional) Output path for autogenerated .xcassets (e.g. /AwesomeApp/AltIcons.xcassets).

Example usage

Have a directory containing your alternative icon image assets, for example:

AltAppIcons/
  dark@2x.png
  dark@3x.png
  pride@2x.png
  pride@3x.png
  festive@2x.png
  festive@3x.png

The filename for each icon will be used as the identifier for Info.plist entries as well as any autogenerated file.

Multiple scale identfiers (e.g. @2x) for the same icon will be parsed correctly and will not result in duplicate cases.

Any autogenerated files will need to be added to your Xcode project (including target membership). If you do this once for each given file, assuming the filename or path has not changed - subsequent runs of Bian will automatically update the added files.

Autogenerate Swift enum

Conditionally generates if a --swift-output path is provided.

⚠️ Any file which already exists at this location will be overwritten.

Example output .swift file

Each enum case .rawValue property will match the file name parsed.

//
// Autogenerated file, changes will be overwritten.
//
enum AlternativeAppIcon: String, CaseIterable {
  case dark
  case pride
  case festive
}

Autogenerate XCAssets

Conditionally generates if a --xcassets-output path is provided.

The names of each asset in the generated .xcassets file will match the filename of the parsed icon image.

⚠️ Any file which already exists at this location will be overwritten.


Integration

As build phase run script

  1. Download the latest Bian release or compile yourself from source.
  2. Copy Bian to a known location within your project directory.
  3. Create a new Build Phases run script from within Xcode (ensure it's before 'Compile Sources').
  4. Write a script to execute Bian on every build.
  5. Add autogenerated files to Xcode target if needed.

Example script:

#!/bin/bash
echo "Generating alternative app icons"

bian="${SRCROOT}/AwesomeApp/Tools/Bian"
icons_dir="${SRCROOT}/AwesomeApp/Resources/App icons"
info_plist_path="${SRCROOT}/AwesomeApp/Info.plist"
swift_path="${SRCROOT}/AwesomeApp/Resources/AlternativeAppIcon.swift"
xcassets_path="${SRCROOT}/AwesomeApp/Resources/AlternativeAppIcons.xcassets"

"${bian}" --icons-dir "${icons_dir}" --info-plist "${info_plist_path}" --swift-output "${swift_path}" --xcassets-output "${xcassets_path}"

Manually

From terminal instance:

./Bian --icons-dir "/AwesomeApp/AltIcons" --info-plist "/AwesomeApp/Info.plist" --swift-output "/AwesomeApp/AltIcons.swift" --xcassets-output "/AwesomeApp/AltIcons.xcassets"

Dependencies


Why the name Bian?

Named after the Bian lian (face-changing) performance art.