Let’s automate Swift builds with Bitrise
Now me and my customer we live in a real happiness.
Me: I just push to master and the automation increases the build number, compiles and submits to Testflight.
He: I no longer drag and drop IPA files into iTunes. I am notified by Testflight that I can access to the latest build my developer submits.
We are safe in Apple environment except the Bitrise which is an open source continuous integration tool for developers.
Now let’s clarify what is this automation.
- An Xcode 7.3.1
- An Xcode project (Swift or Objc) stored in a version control repository
- A git server which stores your repository (Bitbucket and Github works fine)
- A developer account, Apple e-mail and password. The password should be alphanumerical.
- An app-id which can be get from iTunes Connect
- A free Bitrise account
- Distribution Provisioning Profile for the app
- A valid certificate (.P12 file exported from the keychain. Add a passphrase to it.)
- a Podfile in case you use Cocoapods.
Open Bitrise and login with your favourite GIT server. I prefered Bitbucket because they offer 5 free private repositories.
Select your project’s repository.
Add an ssh key to your GIT server. I made Bitrise automatically do this. This ssh key will help Bitrise clone the repo without any password.
Select the branch. This branch should be the distribution branch. Bitrise will start building the project immediately. This is an important step so that be careful until you’ll see a message Validation 👍🏻!
Then add a webhook to you GIT server. A webhook is useful when you push to GIT server. The hook will inform Bitrise to start a build just after the push. This is also called a Trigger.
Now open up workflow and manage it. Add your provisioning profiles and certificates into Code signing & Files page. Enter the passphrase of the .P12 just there.
Now you are ready to start a build. Do it. If you see some red stuff in the console output, change something related in the code base and restart build.
Most probably you are doing something wrong with the fucking signing stuff.
Now open main page of Bitrise and go to Xcode, change some code, press Command + Alt + C and push your commits. Then you should see a build has started in Bitrise.
If you read this you are all 👍🏻 with the build process. You have just binded your Xcode to Bitrise. But the most useful stuff starts right here.
In order to submit to Testflight you should do this manually at first. Second and others will be driven by automation.
Now open up the workflow, press manage workflow button and press workflow editor.
Scroll down and press + button under the Deploy to bitrise step.
Search for Deploy to iTunes Connect (with Shenzhen) and add it to your workflow by selecting it. (If you don’t like Mattt, you can use Fastlane Pilot instead. It works faster)
Enter your Apple Developer Email and password there. Don’t forget to add app-id of your app as well.
If you have Podfile add Cocoapods step just like you added Shenzhen. And configure it.
Now press Save and test it by pushing again.
You are done.
Please add comments below I’ll definitely respond back in a day. Follow me on @Erk Ekin.
Update: Bitrise added this article to their Developer Community. Thank you guys.