Tander Tander - 1 month ago 9
iOS Question

How to add build script Xcode 5?

So I was trying to follow this SO answer:

Better way of incrementing build number?

However when I run the script - it fails with exit code 1. I think thats something to do with the Plist?

Questions:


  1. How do I add the script to the path:


    ${PROJECT_DIR}/tools (sibling to the .xcodeproj directory):

  2. Why am I getting an exit code 1 error?


Answer

I found a solution that worked for me.

I used the two scripts from this git hub repo:

https://gist.github.com/sekati/3172554

For the build number - once this number is just to keep track of my builds I added it to the pre-actions of my build scheme like so:

  • Edit Scheme
  • Expand "Build" section by clicking disclosure triangle
  • Select "Pre-actions"
  • Add "New Run-Script Action"
  • Select "Provide build settings from $YOUR_PROJECT"
  • Add an increment script

This increments the build number every time I build / Run the app.

Then for the version number - I wanted this only to increment when I archive. As this is the stage where I release the app to testers or App store and thus, its important to keep an accurate version number.

To do this:

  • Edit Scheme
  • Expand "Archive" section by clicking disclosure triangle
  • Select "Pre-actions"
  • Add "New Run-Script Action"
  • Select "Provide build settings from $YOUR_PROJECT"
  • Add an increment script

Hope this helps others.