Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Xcode, how to not run certain Run Script Build Phases when running Tests?

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?

like image 230
abc123 Avatar asked Aug 15 '26 04:08

abc123


1 Answers

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"

like image 133
kurtanamo Avatar answered Aug 16 '26 17:08

kurtanamo