Easy CI/CD iOS apps with App Center

App Center logo

App Center is a cloud-based toolset that allows developers to build, test, and distribute mobile applications. In this post I’ll try to show how you can easily automate iOS builds with App Center to improve iOS apps delivery lifecycle.

App Center is free to use to some extent – 240m of build time and a trial for test period. You can check the pricing here.

If you don’t have an account you can create one for free. Registration supports some socials so you can start almost with one click.

Add new app

Once you have an account head to https://appcenter.ms/apps, click „Add app” and fill with some app name.

App Center supports diagnostics and analytics tools. When you create a new app, App Center will show step-by-step instructions how to include those, although that’s not a part of this post. I will focus solely on build & distribution.

Build

To get started you need to connect your repository. App Center supports GitHub, Azure Devops, Bitbucket and GitLab. My guess is that it should cover most of the projects. Once you connect the repository, you have to make few more steps before going further.

Shared scheme

By default Xcode keeps the scheme in the local folders of your computer. You have to make sure you put a shared scheme into the repository so that you can use the provisioning profiles for distribution. Go to Project -> Scheme -> Manage Scheme.

and check the box Shared

If you hadn’t had it shared before, you will have noticed that there’s a new file *.xcscheme waiting to be committed in your repository now. Make sure to commit & push it.

Provisioning profile

Next step is setting up a provisioning profile. This step is required if you want to distribute to live devices. You will require a provisioning profile and a .p12 key for it. Head to developer account -> Profiles -> Add New -> Ad Hoc -> Select App Id -> Select Certificate -> Download.

Since this is an Ad Hoc certificate you need to put the UUID of the phones you use for tests. Make sure to add them under Devices first.

If you don’t have a certificate you need to open Keychain Access, then from toolbar Keychain Access -> Assistant -> „Request a certificate from a certificate authority”. Follow the steps and save a file to your disk. Use it to create a new certificate inside Apple developer account.

Once you have a profile and a certificate, the easiest way is to install it on your system. After that go to Keychain Access, find the certificate, unroll, right click on private key and select export to file.

Now you should have both files: provisioning profile and .p12.

Make sure to select the downloaded provisioning profile as a provisioning profile in the shared scheme under Signing & Capabilities in Xcode.

Finally you can go back to the build definition in App Center.

Build configuration

The definition is really simple. Once the repository is connected, App Center should find all the projects/workspaces in it as well as Shared Schemes. You can select the one that you are interested it. Then you can select Xcode version, add any extra scripts and choose if you want to trigger build yourself or have it triggered on every commit to a branch.

If you have XCTests you can execute them as well. If any fail, the build won’t continue.

The next fields are very important. Make sure to tick Sign Builds and upload your provisioning profile as well as .p12 certificate.

You can also enable Distribute builds. By default you will have one group inside App Center called Collaborators where you account will be added by default. You can use it now for testing, define other groups or use the store settings. You can also invite anyone to your groups. The only requirement is that their devices are added in the Apple Developer’s Device section.

That’s it! Now make some code changes, push to the repository and trigger a build. You should have received an email with a version to be installed on your phone now.

Summary

App Center provides an easy CI/CD tooling for iOS development. Defining a build can be done with a very few steps. It easily integrates with most popular source code repositories and determines the workspaces and schemes in selected repository. Beside setting provisioning profiles right, everything is almost configurable with few clicks.

More than that it also supports testing, custom scripting tool, crash reporting and analytics which I may cover in a future post.


Opublikowano

w

przez

Komentarze

Jedna odpowiedź do „Easy CI/CD iOS apps with App Center”

  1. […] my previous post I was showing how easy it is to distribute an app using App Center. This time I’d like to […]