Xcode9 + Xcode Server = Comprehensive iOS Continuous Integration
At WWDC 2017, Apple announce something that made almost every iOS developer smile, session on ‘What’s New in Signing for Xcode and Xcode Server’. It’s hard to explain, how easy it become to perform Continuous Integration for Apple platforms especially iOS and macOS using Xcode 9 and Xcode Server.
CI Before Xcode 9
The iOS Continuous Integration before Xcode 9 release was very challenging. As people might have tried following things
- Fought long battle to setup CI server machines with certificates and profiles.
- Used Ruby based tool like Fastlane to automate the process of analysing, building, testing and code signing.
- Used other third party cloud CI services like TravisCI, CircleCI or self hosted solutions like Jenkins, TeamCity to use bash scripted build or automated build from Fastlane
- Used tools like xctool by Facebook or Bluepill by LinkedIn to parallelise testing on multiple devices and Simulators.
- Used third party Ruby based tools like xcov, xcpretty for code coverage and test reporting.
- Used Xcode Server with macOS Server app and Xcode Service for CI but still fighting with code signing and parallel execution.
Xcode Server with Xcode 9 made all these things of past. You rarely needs the things above now. Xcode Server handles it all for us so easily. Thank to all the developers working on developer tools to make this happen. Let’s see what’s changes
CI After Xcode 9
In Xcode 9, we have following new CI related features integrated within Xcode
- Xcode Server is inbuilt with Xcode 9 so no need to have separate macOS app.
- Xcode Server bot has new tabs for code signing’ and parallel testing on multiple devices and simulators with automatic provisioning of devices.
- Automatically signing of both development and distribution signing.
- Xcode Server creates distribution IPA with automated or manual signing
- Xcode Sever do not launch simulator anymore still able to run in parallel.
Now, we will see that in action how easy to setup and use Xcode Server.
Setting Up Xcode Server
As mentioned earlier, Xcode Server no longer need macOS Server app, it’s now built inside Xcode. We can see “Servers & Bots” tab in the Xcode Preference. We can setup Xcode Server using local Mac or another Mac. We need to select the Mac and Integration user. See the GIF below to understand process of enabling Xcode Server.
Once the service is running, we are good to create our Xcode bots to perform continuous integration. In this tutorial, we will create a bot for both macOS and iOS application. We will create Bot for Swift package XCFit for macOS and Demo app XCS-Demo for iOS.
Creating Bots for iOS Apps — iOS
We will use Demo app XCS-Demo for iOS to setup Xcode Server. We have regular steps to create bots from Xcode “Product -> Create Bot” and name the bot as “XCFit Bot”. Next step is to add Github Repo to the Bot. We have to add Git Repo with SSH. Xcode will ask you to trust the identity repository. You have to select “Trust” and use credential of existing SSH Key. Once successfully authorised, we should able to configure build. The build configuration is main stage to configure what we want to perform as part of the build. We will see following main configuration options.
- Actions — Analyse, Test, Archive and
Next screen will be on scheduling the Bot integration which is self explanatory.
Next, we have option to add code signing. We can have option to give Xcode Server access to developer portal and it will do everything for us. We have other option to choose certificate from server machine for manual signing.
Automated Code Signing
We we click next we have seen to select devices for testing and there is “Run tests in parallel” tick box which enable parallel execution on multiple simulator.
Once bot finishes running tests, we get nice little reports within Xcode itself. The Test Reporting in Xcode Server looks like this :
Watch it in Action
The entire action looks like this :
Creating Bots for Swift Packages — macOS
Swift packages doesn’t need to be run inside simulator or devices. We can run them on macOS. Let’s create a bot for Swift package XCFit. It’s much simpler and quicker than iOS
We just saw some shiny new features of Xcode Server but what will be benefit that will bring for business or team
- No need to write scripts for build automation or manage CI servers for certificates and profiles
- We can achieve continuous delivery by setting Xcode Server within few clicks
Although, Apple engineers made Xcode Server awesome but there are couple of features still missing
- Support for testing Pull Request just like TravisCI
- Uploading the IPA to iTunes Connect or TestFlight
- do you think anything else ?
With Xcode 9 and Xcode Server, we have almost everything in single place. It’s time to retire many tools from toolbox e.g Fastlane, xctool by Facebook or Bluepill by LinkedIn or other CI servers like TravisCI, CircleCI or self hosted CI solutions like Jenkins, TeamCity. Its time to completely switch to Xcode Server.
Like this post from XCBlog By XCTEQ ? You may also like some of our services like guest blogging or Mobile DevOps(CI/CD) or Test Automation. Chekout our services, open source projects on Github or Follow us on Twitter , Facebook, Youtube , LinkedIn. Download Our XCBlog iOS App to read the blogs offline.