Swiftpack.co -  gbrlCM/LambdaLayoutKit as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Library for helping with AutoLayout code, making it more concise and simple.
.package(url: "https://github.com/gbrlCM/LambdaLayoutKit.git", from: "1.1.2")


Platform SPM

Lambda Layout Kit (LK) is a library for dealing with auto layout in a simpler and modern way, using it you can configure your views layouts inside of closures or using shortcut methods, making your layout code cleaner and more readable.


  • Swift 5.0 or later
  • iOS 13 or later
  • XCode 11 or later


LK uses Swift Package Manager as its distribution method, to use it you can fetch LK via XCode or adding it to your package.swift depencies list.

Via XCode

  1. In a Xcode project, click on "File"
  2. Click on "Swift Packages" and select "Add Package Dependency"
  3. Paste the web url for this repository: https://github.com/gbrlCM/LambdaLayoutKit.git
  4. Set Rules to Branch on "main"

After this, you can fetch the latest changes to the framework by selecting "Update to Latest Package Versions" in step 2.

Via Package.swift

If you don't already have a Package.swift file, create one and add the following .package URL.

import PackageDescription

let package = Package(
    dependencies: [
        .package(url: "https://github.com/gbrlCM/LambdaLayoutKit.git", "1.1.2")


There is two ways to use LK the first is with the layout method inside any UIView, with that you can configure any view constraints inside the configuration closure. The other way is with the shortcut methods for common constraint combinations like stretch the view to another view bounds or center one view inside another.

Layout method:

import UIKit
import LambdaLayoutKit

class SomeViewController: UIViewController {

    @LKView childView: UIView

    overide func viewDidLoad() {
        childView.layout { anchors in
                .top(attachTo: view.topAnchor)
                .leading(attachTo: view.leadingAnchor)
                .trailing(attachTo: view.trailingAnchor)
                .bottom(attachTo: view.bottomAnchor)


Inside LK there is a few shortcut methods for common constraints, some are only available for views with intrinsic size other are available for all kinds of views you can see the relation in the examples bellow.

Pin shortcuts

Pin Shortcuts

Stretch shortcuts

Using layout guides

    childView.stretchToBounds(of: parentView.layoutMarginGuide)

Using Views

    childView.stretchToBounds(of: parentView)


I made this library for learning Auto Layout and how to build libraries. I hope it helps you to write cleaner and clearer layout code.

Next steps

  • Make tests
  • Make a proper doc using Jazzy
  • Study the necessity of more shortcuts


Stars: 1
Last commit: 2 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

2 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API