Auto-increase Build number in Xcode

There are lots of tutorials online showing how to implement automatic Build number increase in Xcode.

The simplest one is adding a new Run Script Phase to Project Build Phases and inserting agvtool bump. Unfortunately, I found that this causes a strange issue when the project build randomly stops at the very end and just shows Build Cancelled without any explanation or error. While this happens only some of the time, the project Archiving process fails with the same outcome pretty much every time.

1040 auto increase build number 0

The solution that worked for me is using the same agvtool method, but in a different place. 

  • Go to Product > Scheme > Edit Scheme 
  • Expand Build > Post-actions
  • Click on + sign, then New Run Scrip Action
  • Choose your project in “Provide build settings from
  • And finally enter script: cd “${PROJECT_DIR}” ; agvtool bump

Build > Post-actions

I found that this works perfectly every time, without random build cancellations.

December 2022
Xcode 14.2
macOS 13.1 (Ventura)


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *