These docs are for v0.12. Click to read the latest docs for v0.16.

Xcode makes programming in Swift faster and more intuitive. You can build and run your Vapor project from inside of Xcode, use code autocompletion, and option-click for documentation.

Generate Xcode Project

To generate and open the Xcode project, run the following command:

vapor xcode

Select Toolchain

Make sure you have the correct toolchain selected by going to Xcode > Toolchains.

696

Vapor 0.11 uses the 06-06 (a) toolchain.

🚧

Wrong Toolchain

Apple makes breaking changes between snapshots. If you use the wrong toolchain, Vapor will most likely not compile.

Build and Run

Select App from the list of schemes and press Command+R or hit the play button to build and run your project.

274

If all goes well, you should see the following printed out in Xcode's console:

1058

Arguments

You can pass arguments to the executable through Xcode just as you would through the command line.

Select Edit Scheme... from the scheme list while App is selected.

406

From there, you can change which arguments are passed on launch.

3026

Important Arguments

Xcode builds and runs the executable in a temporary folder on your file system. This makes the current working directory of the executable different than what it would normally be if you ran vapor run serve.

To get around this, you should include the following arguments in your Xcode scheme.

682
serve
--workdir=$(SRCROOT)

The first argument explicitly runs the serve command. serve runs by default if no command is provided, but this may change in the future. Read more about commands in the Commands section of the Guide.

The second argument passes an Xcode variable for Source Root as the working directory for Vapor. This will allow all of your views and other static to be properly found and rendered.