How can I force Xcode to load .env
file when running Run
scheme of Vapor project?
I have added --env production
to run arguments in scheme configuration but it also did not change behaviour. only setting below Xcode environment variables works (but it is not my goal as they are reset when I rebuild vapor project outside of Xcode.
I have defined there few variables but they fail to load when project runs (key does not exist)
edit:
Updated question to state that I use Vapor 3
For a Vapor 4 project (because there are other steps to make .env files to work in Vapor 3) - have you set the custom working directory for the scheme? Because of the way SwiftPM support works in Xcode, the Vapor project can't detect where the project lives, so if you set the custom working directory to your project's directory, it will search in there for .env
files on launch.
For Vapor 3 you need to follow the steps above but also add support for .env files as described in this gist