Stevia is a Swift library that provides a concise domain-specific language for writing Auto Layout constraints in code.
The library addresses the verbosity and maintainability problems of native NSLayoutConstraints by offering three complementary APIs: a visual layout API, a chainable API, and an equation-based API. All three approaches generate native NSLayoutConstraints under the hood. The tool is designed to make Auto Layout code readable and expressive, reducing boilerplate significantly compared to writing constraints manually. The README demonstrates that a typical login view can be implemented in roughly half the code when using Stevia compared to native constraints, while being substantially more maintainable. The library integrates with live code injection tools like InjectionForXcode to enable real-time view development without restarting the app.
Stevia suits iOS developers who prefer writing layouts in code rather than using Interface Builder, XIBs, or storyboards. It is particularly valuable for teams that want to reduce merge conflicts and maintenance overhead associated with visual layout files. The tool works well in projects where view code needs to be version-controlled cleanly and debugged without switching between multiple file formats. The README positions Stevia as an alternative to both traditional Auto Layout and other layout abstraction approaches, emphasizing that it generates native constraints rather than introducing a custom layout engine.
The project maintains active development with regular updates to support current Swift tooling. The library has transitioned to Swift Package Manager as its primary distribution method, with legacy package manager support deprecated. Documentation is comprehensive and includes practical examples such as a starter project demonstrating typical use cases.