Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scheme Script vs. Build Phase Script

Tags:

xcode

After I make a build I want to copy some files into my Xcode project.

I discovered that I could do this either in

  1. In "Build Phases" with a custom build step.

  2. I can also execute scripts before and after the different "tasks" in the Scheme editor:

    • Build (This is where I could add my script)
    • Run
    • Test
    • Profile
    • Analyze
    • Archive

I don't completely understand the differences / possible implications between the two approaches and I am wondering when to choose either approach. Thanks for clarification.

like image 508
Besi Avatar asked Oct 25 '12 09:10

Besi


1 Answers

After I make a build I want to copy some files into my Xcode project.

I assume you want to copy files to your build product, not the Xcode project.

There are several subtle differences between scheme and build phase scripts. Here are some of them:

  • Scheme scripts are part of the scheme, so sharing with other developers is more configurable. Build phase scripts on the other hand are part of the target and cannot be skipped simply by choosing another scheme.
  • Scheme scripts can run before the dependency checking. So you can use them to modify source files and get up to date results. This is not possible with build phase scripts.
  • The information passed to the script in environment variables differs slightly. Depending on what information you need you sometimes have to choose right kind of script.
  • Build phase scripts are run conditionally only if the build process succeeds until their place in the target.
  • Build phase scripts can be configured to only run when input files changed.
like image 97
Nikolai Ruhe Avatar answered Oct 11 '22 22:10

Nikolai Ruhe