top of page
Search
  • Writer's pictureNeil Burchfield

A simple Swift CI Build Manager

For our iOS CI build process, we use Fastlane, a Ruby-based open-source build and release manager for mobile applications. It's a great asset for managing our distribution pipeline. A large portion of that pipeline is hosted within an Xcode Server which uses hooks to determine when we merge pull requests into our versioned branches which is setup to distribute beta builds via TestFlight.


We have multiple people pushing code and merging pull requests simultaneously, which led to an issue regarding build version incrementation. To put into perspective, Developer A would merge Developer B's PR, Developer C would create a PR that would get approved that Developer D would eventually approve and merge. At this point we have multiple distribution pipelines enqueued, serially, awaiting execution from our Xcode Server. Due to the fact that the version would increment, including committing to Git, the next build was already enqueued which inevitably caused the versions to become out of sync, especially on days where we were pushing a lot of code. This led to a bottleneck in our pipeline causing long wait times ultimately for TestFlight to return errors relating to duplicate or versions that were less than the previous. Frustrating right?


We tried several open source alternatives, many medium articles, white-boarding sessions. Our distribution pipeline wasn't super complex... it fit our needs, we just had this one hiccup. One day, we decided to simplify the process. We extracted the version incrementation from our Fastlane process and instead handled it on the CI Server itself. We wrote a dead simple version manager that could invoke directly on the CI server instead.


Save the following file and compile:

Then use the executable to store a reference to the latest build version of your application:


And to retrieve the latest version:


Which in this case, will return "1", since we previously set that as the build number for the corresponding version.

You can also reset the version entirely:


As you can see, nothing complex, although a simple solution for a somewhat complex problem. We've used this to uphold our current distribution pipeline although moving forward, we plan to use other tools that would ideally handle our build versions automatically.


Feel free to check it out here.


16 views0 comments

Recent Posts

See All

Comments


bottom of page