How to set a custom working directory in Xcode
With the introduction on Xcode 11, Swift Package Manager finally has first class support! This makes working with SwiftPM projects in Xcode so much nicer.
However, it also means that Xcode runs the application in a randomised directory inside
DerivedData. For apps that need to load resources, such as template files or
.env files (hello Vapor! 👋), this presents a problem. So to work around this you can set a custom working directory in Xcode, so Vapor can work out where to look for files.
OPTION+CLICK the scheme (the thing next to the play button with your app name) to edit the scheme. Select Options and check Use custom working directory and add in the directory to your project path. It should look something like:
That's all you need! Now Vapor can detect env files, Leaf files and also static files in the
Public directory when using