xcode pass target name to run script build phase

1.3k Views Asked by At

I'm developing a cocoapod (MySDK in the screenshot below) that runs a script as part of its installation. I need to pass the name of the main executable (i.e. SecThree) to that script, i.e. $FOO below:

enter image description here

I thought I could use $PRODUCT_NAME, $TARGET_NAME, or $EXECUTABLE_NAME, but of course these are MySDK when run within the MySDK target.

How could I resolve the name of the main target from within a script in its dependencies?

1

There are 1 best solutions below

0
On

I don't think there is a built-in way, but an easy work-around is to just create a variable before calling sh myscript.sh --app-name=${FOO}:

TARGET_NAME="MySDK"

sh myscript.sh --app-name=${FOO}

Now you can access $TARGET_NAME inside myscript.sh