How to access $ {SRCROOT} user script?

I have a script user who would like to access $ SRCROOT to get a file that is part of the project but does not see to make it work. If I create a simple user script as follows: echo "$ {SRCROOT}" with the output set to replace the selection, nothing is output except a new line.

Is there a way to access env vars from user scripts?

0
source share
1 answer

Yes, you can access environment variables from user scripts, but the problem is that SRCROOT is a build parameter, not an environment variable. It is valid only during assembly, and not during editing.

If you need the location of the very first project, the next line will write this to stdout. You can use standard shell path processing to get what you want from it.

#!/bin/sh
osascript -e 'tell application "Xcode"' -e 'full path of project of active project document' -e 'end tell'
+2
source

All Articles