After nearly four years and over 500 stars on GitHub, I've decided it's time to retire MarkupKit. Despite a respectable level of developer interest, the idea of building an application using XML never seemed to fully resonate with the broader iOS community.
However, even in the absence of a markup-based implementation, the concept of declarative UI is still highly applicable. Today I am happy to introduce Lima, a new Swift-based DSL for constructing iOS and tvOS applications. The project's name comes from the nautical L or Lima flag, representing the first letter of the word "layout":
Lima retains most MarkupKit functionality, and improves on it in a number of ways:
- Because it is written in Swift, UI code written using Lima is compiled. This means it is validated at build time rather than at run time. The lack of compile-time validation was a major drawback to the markup approach.
- Further, since it is a Swift-based DSL, developers can finally take advantage of code completion. Although I experimented with a number of different approaches over the years, this is something I was never quite able to get working in XML.
Again, because it is written in Swift, Lima code is refactorable. It facilitates better code reuse, and allows developers to employ modern Xcode features like image and color asset literals in UI declarations. Lima also reduces overall file count, since a separate XML document is no longer required.
Converting markup to Lima syntax is straightforward. For example, given this markup:
<LMColumnView spacing="16"> <UIImageView image="world.png"/> <UILabel text="Hello, World!"/> </LMColumnView>
the Lima equivalent is as follows:
LMColumnView(spacing: 16, UIImage(image: UIImage(named: "world.png")), UILabel(text: "Hello, World!") )
It's just as readable, and even slightly more concise, since there's no need for closing tags.
Thanks to everyone who has supported or contributed to MarkupKit. I'm hoping you will find Lima even more useful!
For more information, please see the project README.