Swift CLI package and custom, relative working directory

I'm trying to convert some of my internal CLI tools from Xcode projects to Swift packages.

When debugging, I need to be able to start the tool using a custom working directory relative to the project/package directory. I can set this in the scheme config under "Options - Working Directory - Use custom working directory".

It works fine for absolute paths but I can't figure out how to get a relative path (ie. 1 level down from the package directory).

Previously, I used $(PROJECT_DIR)/../ for this but for my Swift package based tools, this just ends up as / when starting the app. I also tried $(SRCROOT) but then Xcode even shows an alert The working directory "$(SRCROOT)" for scheme "PackageName" doesn't exist.

Does anyone know how to achieve this?

$(PROJECT_DIR) and $(SRCROOT) both cause The working directory "$(SRCROOT)" for scheme "PackageName" doesn't exist. However specifying default value explicitly works: $(BUILT_PRODUCTS_DIR)

I am wondering this too. $(BUILT_PRODUCTS_DIR) seems to be the only variable I could reliably get to work, but it points to the build artifacts, which are located in ~/Library/Developer/Xcode/DerivedData/..., which unfortunately does not really help in getting it to locate the package/source directory.

Swift CLI package and custom, relative working directory
 
 
Q