I observed the custom shell scripts executed by Xcode, in Run Script Phase, do not have any environmental variable set. They have tons of other variables but not the PATH.
Is it possible to solve this problem, how? I just want to run a tool that is supposed to be in path and I do not want to start checking manually possible locations.
First of all make sure you have executable permission for your script. And then, Run your script using ./portblock.sh or using sh portblock.sh . If you don't like to run the script with above mentioned way then update your PATH variable to the script directory.
1 Select xcodeproj file of you project -> Select Target -> Select Build Phases -> Click on plus button (upper left corner) -> Select New Run Script Phase. 2If you want to run a script while it is being installed on the device then please check a little checkbox just below the script box.
You could explicitly source the users .bashrc
, .profile
etc. Or better yet, run something like
PATH=$(bash -l -c 'echo $PATH')
which won't risk polluting other variables.
Ivan Andrus' answer led me to what I think is a cleaner and more complete method: run the script within a new shell altogether. For example:
bash -l -c "./configure --prefix=${DERIVED_FILE_DIR} && make && make install"
I'm using double-quotes for variable expansion. It's a good idea to expand out any variables you need, because any existing vars might be overwritten by the ones created for the new environment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With