Rob Segal
Rob Segal

Reputation: 7625

$SRCROOT not recognized in shell script attached to XCode project

Trying to run a simple script attached 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 run fine if I run it outside of XCode but when running from XCode I'm getting the following error...

line 2: SRCROOT: command not found

Seems the SRCROOT variable isn't detectable in the script but my understanding was that this is one of the environment variables that should be passed and accessible to the script. Any thought?

Upvotes: 6

Views: 6082

Answers (1)

Rob Segal
Rob Segal

Reputation: 7625

Turns out this was my fault. The script was actually not being called at all. In XCode I was referring to the path of the script using...

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

Switching it to...

"$SRCROOT/myScript.sh"

Corrected the problem and indeed I can access $SRCROOT from my script now.

Upvotes: 13

Related Questions