UIViewKit Review

UIViewKit main image

What is UIViewKit?

UIViewKit is an iOS framework that makes writing, previewing, and debugging UIViews programmatically in a Swift-like way. 

Thanks to DSL, the UIView definition looks like Xib, Storyboard source code, or SwiftUI View.

Included with framework tools like FreeForm Previews, it gives instant visualization for different view sizes. 

The idea behind the framework is to provide as much experience as possible in writing views like dragging and dropping views in Interface Builder.

What does UIViewKit do?

Users can make the most out of the framework to recreate the experience of creating UIViews in Xcode Interface Builder but with Swift DSL code. 

It helps to write Swift Compiler-typed UIView hierarchy code programmatically, which, compared to linear UIView hierarchy code, is easy to reason about. 

UIView hierarchy, configuration, and refactoring are as easy as SwiftUI code, which is one of the standout features.

Benefits and unique features of UIViewKit

The framework is built of the following modules:

  • DSL: Write and configure views programmatically in a hierarchical style in a Swift-like way.
  • Previews: A collection of specialized previews, FreeForm Preview helps to visualize a view in different sizes, as Interface Builder does.
  • Debug: Functions that print view subview hierarchies, set colors, or activate borders to subviews to make them easily spotted.
  • Constraints: Similar to Interface Builder Constraints generator. A one-liner, powerful constraints generator.
  • ViewController: A collection of functions that help configure ContainerViews and replace views.

Cons of UIViewKit

Developer team members must learn how UIKit Storyboard was changing default values of UIViews compared with those created in code. 

An example is backgroundColor, which in UIView created in code is ‘clear,’ and in Storyboard, it is ‘White.’

How much does UIViewKit cost?

The framework is open-sourced under the MIT license, which means that UIViewKit is free to use and has very few modification and code redistribution restrictions.