# Building on swift build

**URL:** <https://forums.swift.org/t/building-on-swift-build/10755>\
**Category:** Package Manager\
**Created:** [March 9, 2018, 11:33am UTC](https://forums.swift.org/t/building-on-swift-build/10755 "2018-03-09T11:33:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![samdeane](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/samdeane/32/2175_2.png) [@samdeane](https://forums.swift.org/u/samdeane)\
**Post date:** [March 9, 2018, 11:33am UTC](https://forums.swift.org/t/building-on-swift-build/10755/1 "2018-03-09T11:33:35Z")

</div>

I made a little experimental build tool which sits on top of `swift build` and allows you to do some of the things (settings, custom build phases) that are arguably missing from the non-Xcode build experience.

I've written a bit about it [here](http://elegantchaos.com/2018/03/06/building-on-swift.html), or you can [go straight to the code](https://github.com/elegantchaos/Builder).

I'm not at all confident that it's the way to go, but I'd be interested in any feedback. I guess you could think of this as a pitch for a pre-proposal proposal (or something).

---

<div class="post-metadata">

**Author:** ![ckeithray](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/ckeithray/32/2317_2.png) [@ckeithray](https://forums.swift.org/u/ckeithray)\
**Post date:** [March 9, 2018, 3:56pm UTC](https://forums.swift.org/t/building-on-swift-build/10755/2 "2018-03-09T15:56:05Z")

</div>

Nice. Thank you for doing this.

---

<div class="post-metadata">

**Author:** ![samdeane](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/samdeane/32/2175_2.png) [@samdeane](https://forums.swift.org/u/samdeane)\
**Post date:** [March 15, 2018, 7:56pm UTC](https://forums.swift.org/t/building-on-swift-build/10755/3 "2018-03-15T19:56:01Z")

</div>

The upcoming [extensible build tools proposal](https://forums.swift.org/t/package-manager-extensible-build-tools/10900) may well make this experiment obsolete, but I've been continuing to tinker around with it anyway, for my own amusement.

I've split the example out into [a separate repo](https://github.com/elegantchaos/BuilderExample), which illustrates how it's nicely able to pull in its own tool dependencies, including `builder` itself.

I've also worked a bit on a cleaner way to specify settings and schemes/actions, using a similar style of syntax to Packages:

```swift
import BuilderConfiguration

let settings = Settings(schemes: [
    .scheme(
        name: "common",
        swift: ["Dexample"],
        inherits: [
            .scheme(name: "mac", filter: ["macOS"]),
            .scheme(name: "debug", filter: ["debug"])
        ]
    ),
    .scheme(
        name: "mac",
        swift: ["target", "x86_64-apple-macosx10.12"]
    ),
    .scheme(
        name: "debug",
        swift: ["Onone"]
    )
    ]
)

let configuration = Configuration(
    settings: settings,
    actions: [
        .action(name:"build", phases:[
            .toolPhase(name:"Preparing", tool: "BuilderToolExample"),
            .buildPhase(name:"Building", target:"Example"),
            .toolPhase(name:"Packaging", tool: "BuilderToolExample", arguments:["blah", "waffle"]),
            ]),
        .action(name:"test", phases:[
            .testPhase(name:"Testing", target:"Example"),
            ]),
        .action(name:"run", phases:[
            .actionPhase(name:"Building", action: "build"),
            .toolPhase(name:"Running", tool: "run", arguments:["Example"]),
            ]),
    ]
)

configuration.outputToBuilder()

```

It would still be far better to be able to hook directly into `llbuild`, which is what the extensible build tools proposal is aiming for, but in the meantime...

---

<div class="post-metadata">

**Author:** ![samdeane](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/samdeane/32/2175_2.png) [@samdeane](https://forums.swift.org/u/samdeane)\
**Post date:** [April 24, 2018, 7:45pm UTC](https://forums.swift.org/t/building-on-swift-build/10755/4 "2018-04-24T19:45:28Z")

</div>

I got distracted by various other projects, but I've been tinkering around a bit more with this recently - with a view to adding some sort of rudimentary resource packaging to it.

I'll probably write that up in a future blog post, but before doing that I went back and blogged [a little more detail about the stuff I've done so far](http://elegantchaos.com/2018/04/24/more-build-adventures.html).
