Reputation: 8293
My project is currently setup so that the MyApp target includes a few Run Script Build Phases. These scripts depend on the sequence of Build Phases. For example, there's a script that runs before Copy Bundle Resources and another one that runs afterwards.
My test target depends on MyApp, so when I run the tests (Product Menu, Test), I'd like to not include some of these scripts because it slows the testing down.
I thought to create an Aggregate Target which includes MyApp target. Then move the scripts I don't want to run when testing out of MyApp and into the Aggregate. However, I don't see how I can configure the same sequence of when these scripts will run by doing this.
Is there a way to do this? Or perhaps a better solution all together?
Upvotes: 7
Views: 4234
Reputation: 61
It depends on what your scripts doing:
You can create a Pre-Action (go to "edit-scheme") - there you can add a run script and it will be only executed when your running selected scheme. What you have to know is: Pre-Actions are on another thread, so if you want to stop the building process it won't work
If its possible: You can check your script if "debuging" or "releasing" you can use this if its enough to check just this two options like:
wantedConfig="Debug"; currentConfig="$CONFIGURATION" if [ $currentConfig=$wantedConfig ]; then echo "Now Im on a debug mode and will do all you want here"; fi You also can create your own environments variables like:
TEST_MODE=YES
..and use it like example above:
currentConfig="$TEST_MODE"
The logic is there, but it keeps coming inside the if even thoug the configuration is different. After some debugging and searching this is the working snippet :
wantedConfig="PROD"
currentConfig="${CONFIGURATION}"
echo "currentConfig = $CONFIGURATION"
if [ "$currentConfig" = "$wantedConfig" ]; then
echo "begin action"
fi
Upvotes: 0
Reputation: 1828
It depends on what your scripts doing:
You can create a Pre-Action (go to "edit-scheme") - there you can add a run script and it will be only executed when your running selected scheme. What you have to know is: Pre-Actions are on another thread, so if you want to stop the building process it won't work
If its possible: You can check your script if "debuging" or "releasing" you can use this if its enough to check just this two options like:
wantedConfig="Debug"; currentConfig="$CONFIGURATION"
if [ $currentConfig=$wantedConfig ]; then
echo "Now Im on a debug mode and will do all you want here";
fi
You also can create your own environments variables like:
TEST_MODE=YES
..and use it like example above:
currentConfig="$TEST_MODE"
Upvotes: 2