Hwee-Boon Yar

Hi, I'm Hwee-Boon Yar

I write, ship and sell software products. iOS/OS X app developer based in Singapore, working remotely. This is my blog.


Need to run a code review on your codebase? Hire me

Zhi — Swift Library for Live Reloading Auto Layout Constraints on iOS


Being able to live reload UI changes during development is a boom for productivity. We have seen it in other environments such as Smalltalk, Self. We also have it on iOS in the form of Injection Plugin for Xcode and React Native.

Zhi is another attempt at this.

It lets you tweak Auto Layout constraints and watch your app update immediately without a rebuild + run cycle.


This library allows you to specify your auto layout constraints in separate .styles files. It supports:

  • Live reloading of Auto Layout constraints as you save the .styles files, without a rebuild + run cycle
  • Apple's Visual Format Language: H:[p(==v2)]|
  • Support an equations-based syntax: v1.width = v2.width + 10

In addition, the .styles files also support:

  • Metrics can be specified
  • Colors — rgb(), rgba() or named colors in UIColor, e.g. red
  • Image filenames
  • Button title and label text
  • Font name, size
  • Dynamic type style names, e.g. callout or caption1
  • and more

This means that you can tweak these properties without rebuilding your app during development.

There is an example app included in the repository.

Styles Files Syntax

You write a style file for each view controller that you want to use Zhi with.

Styles files are line-based. Empty lines are ignored

Comments start with a single #

# This is a comment

Metrics start with ##


Visual Format Language:


Equation-based syntax:

v1.width = v2.width*2


v1.backgroundColor = rgb(90, 200, 250)

i.backgroundColor = gray
i.contentMode = scaleAspectFill
i.clipsToBounds = true
i.image = color.jpeg

b.title = Tap Me
b.textStyle = largeTitle

l.fontName = Thonburi
l.fontSize = 30
l.numberOfLines = 0

WARNING: Setting of properties like colors are best used in style files only during development. Ship style files that only contains instructions for Auto Layout.


Refer to the README for installation and usage instructions.


BSD 2-clause


Like this post? Follow me on Twitter.