Automate nightly iOS builds for free using just your MacBook
A few weeks ago I found myself wanting a build system for publishing nightly builds of the app that my startup was working on to Testflight.
Having nightly builds felt like the perfect way to iterate faster: each day, we’d wake up and use the latest version of our app with the changes we’d made the day before. We’d be able to catch bugs quickly, and try out the new features we added. I considered using existing build systems like Github Actions and Xcode cloud, but of course they cost money.
And that was my only problem: I wanted to do this for free. I didn’t want to spend money on a CI/CD platform for our 2 person startup, but I also didn’t have a spare Mac lying around to automate these builds. So I decided to figure out how to do it using just the MacBook Air I’m typing this on right now (my daily laptop).
I’m happy to report that it’s very possible, and it works very well. Every night at 2 am my MacBook Air runs a fastlane build of our app and publishes it to Testflight. This happens with the lid closed while its charging, but it’ll even run on battery power with the lid closed (the build will take longer though).
The setup process is not that bad either. Here’s a high level overview of how it’s done:
Setup fastlane to publish to testflight
Write a shell script that will start fastlane and login to keychain (fastlane stores credentials for uploading to testflight in keychain)
Use
pmset
to wake the laptop at a specified time (pmset is a built in utility for managing power settings)Create a
launchagent
to run the fastlane build in the background after pmset turns on the laptop
I’ve been using this local build system for about a month now, and it’s worked extremely well. I couldn’t find anything about this online, so I decided to write this short post. If there’s any interest, I could write a more detailed set of instructions or turn it into an open source project which lets you do this with a 1 click install (lmk!).