Have you ever come across this build error in Xcode..
I'm sure you have.
During my first years of iOS development, this has been one of the most ambiauious errors for me, I can only see that I've messed up somewhere in the codebase and I have to go and see what I've done wrong, however, after I got to know build phases better in Xcode this couldn't make more sense..
Build Phases
In Xcode build phases section is the scope where Xcode offers you the possibility to run custom scripts - known as run scripts - as part of the build process, these script can be tailored for any behavior you can think of. The cool thing though is that you can control the build process through this powerful script of you..
Let's better have an example..
For Starter, How can we add those run scripts?
- Head to you project file.
- Choose your app target.
- Navigate the build phases tab.
- Click the + button and choose
New Run Script Phase
This will add a run script template for you..
- You can give a cool name to your script.
- This is the path you shell on your machine.
- The Shell script that will be run during the building process.
Note: All these run scripts will run serially, and you can change the order by grabbing the run script and moving it up or down.
For our very first run script, we will be doing something very simple..
Just printing some message to the user..
This message however won't be printed to the log. Instead, you can access it through the build report.
- Navigate to the report navigator.
- Choose your build of interest.
- Choose all messages tab.
- You will find the message printed.
Now let's tweak this build a little, let's break the build for no reason..
The key here is to exit the script with any value rather than zero, this will indeed fail the script and all the succeeding run scripts won't even run.
This will result in our friendly message we now understand its meaning.
So this is it for our first part, in the next part we will build upon our knowledge and develop a very useful run script to use in you apps, so stay tuned 😉
Top comments (0)