Skip to content

Xcode

This page goes over some tips and tricks for using Xcode. If you use a different development environment, you can skip this.

Custom Working Directory

By default Xcode will run your project from the DerivedData folder. This folder is not the same as your project's root folder (where your Package.swift file is). This means that Vapor will not be able to find files and folders like .env or Public.

You can tell this is happening if you see the following warning when running your app.

[ WARNING ] No custom working directory set for this scheme, using /path/to/DerivedData/project-abcdef/Build/

To fix this, set a custom working directory in the Xcode scheme for your project.

First, edit your project's scheme by clicking on the scheme selector by the play and stop buttons.

Xcode Scheme Area

Select Edit Scheme... from the dropdown.

Xcode Scheme Menu

In the scheme editor, choose the App action and the Options tab. Check Use custom working directory and enter the path to your project's root folder.

Xcode Scheme Options

You can get the full path to your project's root by running pwd from a terminal window open there.

# verify we are in vapor project folder
vapor --version
# get path to this folder
pwd

You should see output similar to the following.

framework: 4.x.x
toolbox: 18.x.x
/path/to/project