$ SRCROOT is not recognized in a shell script attached to an Xcode project

Trying to run a simple script connected to my xcode project as follows:

if [ -d '$HOME/data' ]; then cd "$HOME/data/" rsync -t *.plist '$SRCROOT/data/' fi exit 0 

The script seems to work fine if I run it outside of Xcode, but when I run from Xcode I get the following error ...

 line 2: SRCROOT: command not found 

The SRCROOT variable does not seem to be detected in the script, but I understand that this is one of the environment variables that must be passed and accessible to the script. Any thought?

+6
source share
1 answer

It turns out that it was my mistake. the script was not actually called at all. In Xcode, I referenced the script path using ...

 "./$(SRCROOT)/myScript.sh" 

Switching to ...

 "$SRCROOT/myScript.sh" 

The problem is fixed, and now I can access $ SRCROOT from my script.

+10
source

Source: https://habr.com/ru/post/896373/


All Articles