Xcode9 + Xcode Server = Comprehensive iOS Continuous Integration
Xcode Server can now be used for easy continuous integration and testing on iOS and macOS with testing bots. Learn how to build them here.
Join the DZone community and get the full member experience.Join For Free
at wwdc 2017, apple announced something that made almost every ios developer smile: a session on what's new in signing for xcode and xcode server . it's hard to explain how easy it has become to perform continuous integration for apple platforms, especially ios and macos, using xcode 9 and xcode server.
ci before xcode 9
ios continuous integration before the xcode 9 release was very challenging. people might have tried the following things:
- fought a long battle to setup ci server machines with certificates and profiles.
- used ruby-based tools like fastlane to automate the process of analyzing, building, testing, and code signing.
- used other third party cloud ci services like travisci , circleci , or self-hosted solutions like jenkins or teamcity to use a bash build script or automated build from fastlane .
- used tools like xctool by facebook or bluepill by linkedin to parallelize testing on multiple devices and simulators.
- used third party ruby-based tools like xcov and 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 this a thing of the past. you rarely need the things above now. xcode server handles it all for us so easily, thanks to all the developers working on developer tools to make this happen. let's see what 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 there's no need to have a 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.
- automatic signing of both development and distribution signing.
- xcode server creates distribution ipa with automated or manual signing
- xcode sever does not launch a simulator anymore, but is still able to run in parallel.
now we will see in action how easy it is to setup and use xcode server.
setting up xcode server
as mentioned earlier, xcode server no longer needs a macos server app; it's now built inside xcode. we can see the "servers & bots" tab in the xcode preferences. we can setup xcode server using a local mac or another mac. we need to select the mac and integration user. see the gif below to understand the 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 applications. we will create a bot for the swift package xcfit for macos and a demo app, xcs-demo , for ios.
creating bots for ios apps - ios
we will use the demo app xcs-demo to set up xcode server for ios. we have regular steps to create bots from xcode “product -> create bot” and name the bot as “xcfit bot.” the next step is to add the github repo to the bot. we have to add the git repo with ssh. xcode will ask you to trust the identity repository. you have to select “trust” and use credentials of an existing ssh key. once successfully authorized, we should able to configure the build. the build configuration is the main stage to configure what we want to perform as part of the build. we will see the following main configuration options:
- actions - analyse, test, archive, and
the next screen will be on scheduling the bot integration, which is self-explanatory.
next, we have the option to add code signing. we have the option to give xcode server access to the developer portal; it will do everything for us. we have another option to choose a certificate from the server machine for manual signing.
automated code signing
once we click next, we have to select devices for testing. there is a "run tests in parallel" tick box which enables parallel execution on multiple simulators.
once the bot finishes running the 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 don't need to be run inside simulator or devices. we can run them on macos. let's create a bot for the swift package xcfit . it's much simpler and quicker than ios.
we just saw some shiny new features of xcode server, but what benefits will it bring for a 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 with a few clicks.
although apple engineers made xcode server awesome, there are a couple of features still missing:
- support for testing pull requests like travisci.
- uploading the ipa to itunes connect or testflight.
with xcode 9 and xcode server, we have almost everything in single place. it's time to retire many tools from the toolbox, e.g. fastlane , xctool by facebook, bluepill by linkedin, or other ci servers like travisci , circleci , or self-hosted ci solutions like jenkins and teamcity . it's time to completely switch to xcode server.
Published at DZone with permission of Shashikant Jagtap, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.