开发者

How to access ${SRCROOT} in a user script?

I have a user script that I would like to be able to access $SRCROOT in order to get a file that is part of the project but can't see to get it to work. If I create a simple user script as so: echo "${SRCROOT}" with the output set to replace selection nothing is output except the newline.

Is there a way to access env vars from user scrip开发者_开发技巧ts?


Yes, you can access environment variables from user scripts, but the problem is that SRCROOT is a build setting, not an environment variable. It's only valid at build time, not at editing time.

If what you want is the location of the frontmost project, the following line will write that 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'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜