CI/CD with Xcode Server 10

Xcode Server is a powerful and easy-to-use CI/CD solution that every Xcode 10 developer already installed — even though many of them don’t know it! In this article, I’ll overview the product architecture and discuss some of the plus and minus factors for using Xcode server vs. 3rd-party alternatives.

What does Xcode Server Do?

Like other CI/CD platforms, Xcode Server’s primary role is to automate the integration, analysis, unit testing, assembly and distribution of applications.

Typical use cases include:

  • Pulling an integration or distribution branch from a source code repo when commits are made (and/or on a nightly schedule).
  • Automatically run unit tests to verify that new code commits haven’t introduced regressions or performance problems.
  • Run static analysis of code to detect issues before application assembly.
  • Build QA or production application packages (archiving, in Apple speak).
  • Distribute completed archives to internal (ad-hoc) or external (Test Flight, Crashlytics, etc.) points.
  • Notify the Development, QA and Product teams of new build status, completions and exceptions.
  • Do all of the above continuously — perhaps several times per day — allowing developers to go back to work on their next tasks while these essential but repetitive tasks are completed by automated processes.
Xcode Server Build Process Overview

Many of the tasks Xcode server does are fully baked-in automation steps. Others are custom scripting tasks can be added to plug holes in the built-in capabilities — and add entirely new process steps limited only by a developer’s imagination.

Xcode Server History

First introduced by Apple with Xcode 5, Xcode Server is a first-party CI/CD solution — i.e. delivered and supported directly by Apple. When first introduced, Xcode server was one of many modules included in OS X Server (now known as macOS Server). In addition to CI/CD capabilities, OS X Server of that era included:

  • Email server
  • DNS Server
  • Git repository server
  • User profile management
  • And more…

Over time, Apple has pared back what is now branded macOS Server, removing many of the features that aren’t specific to macOS — and were probably under-utilized or not needed by customers. Today, macOS server still remains as a system administration layer over macOS for system administrator use, while Xcode server has been relocated into the Xcode.app product.

Xcode Server in Xcode

With Xcode 9 and Xcode 10, Xcode server is integrated with Xcode, rather than integrated with macOS server. This has several advantages:

  • Every installation of Xcode also installs Xcode Server and can be used directly
  • No need to license or install macOS Server on the remote integration server
  • Overall tighter integration with Xcode
  • A more familiar user experience for developers configuring Xcode Server.

With full Xcode integration, installing Xcode server really couldn’t be easier — just install Xcode, and Xcode server is installed as well. All that’s left is to enable it in preferences and select a user, on a new tab within the Xcode preferences screen.

Enabling Xcode Server in Xcode 10 Preferences

Running Locally or on an Integration Server

Xcode Server is installed along with Xcode 10, so does that mean your own development workstation can be your CI/CD server? The answer is — Yes! This is certainly possible, and may make sense for projects where the developer is working alone or with a very small team on a project — but would still like to take advantage of integration automations rather than running tasks manually.

Running on a Dedicated Integration Server

Probably more common is for a team of developers working on a product to use Xcode server as an automated integration point. This scenario doesn’t change typical developer workflow too much.

A lead developer or Devops staff would install and configure Xcode Server on a dedicated Mac, and then most developers would push code updates to remote git branches. Xcode server would then run its bot magic either on git push events, or on a scheduled event, e.g. nightly integration tests and builds.

Xcode server supports Subversion as well as git, though the latter is more commonly used today.

Developers contributing to a shared Xcode Server Installation

When used as part of an integration server deployment, it’s most common to deploy a dedicated Mac on a LAN — for example a headless Mac Mini dedicated to the task of fetching committed branches and running integration bots.

When deploying an integration server on a LAN isn’t a viable solution (e.g. remote teams), a Mac can be rented in the cloud, which is an economical way to deploy a headless Mac Mini in a professionally-managed data center. Popular Mac Mini hosting providers that can provide cloud-based hardware that even small teams can afford:

Mac Stadium

Mac In Cloud

XCLOUD

Currently there isn’t a platform-as-a-service (PAAS) offering for Xcode Server (a la Microsoft App Center or Circle CI). However, Apple’s recent acquisition and curtailment of the Buddy Build PaaS provider raises the obvious question: “is there an Xcode Server PAAS offering under development?” As with most new Apple product development, the answer is: “Nobody outside Apple knows!”

Xcode Server Alternatives

Even for iOS/macOS developers, Xcode Server isn’t the only option available. Popular open source tools or commercial services that can serve as viable Xcode Server alternatives include:

Fastlane

Jenkins

Microsoft App Center

Circle CI

Xcode Server Advantages compared withAlternatives

  • Xcode Server is arguably the easiest-to-use CI/CD solution for iOS or macOS application development. The software is already installed with Xcode, and gnarly issues like certificate management and build scripting is — for straightforward use cases — automatic and painless for the developer.
  • Apple supports and regression tests updates to Xcode server along with the Xcode product.
  • Except for the cost of dedicated server hardware (which is optional), Xcode server requires no additional up-front or ongoing operating costs for development teams.
  • Xcode Server can run unit and UI tests on physical iOS devices. Simply attach test iPhone/iPad devices to the Xcode Server, and add them to the test integration for the bot to run. Simple.

Xcode Server Disadvantages compared with Alternatives

  • Xcode Server is not cross-platform, and supports only Apple OS target applications.
  • The lack of a PaaS offering (at time of this writing) means to deploy Xcode Server requires you to provide hardware. This can take the form of a Mac mini (or other type of Mac) yourself, or renting a Mac from a cloud provider. However, this is also true of open source alternatives such as Fastlane/Jenkins — which are on-premises software too. It’s also true that the cost of a Mac may not exceed the cost of commercial PaaS offerings such as Circle CI or Microsoft App Center in the long-run.
  • Out-of-the-box, Xcode Server lacks some features found in other solutions. For example, Xcode Server (at time of writing) doesn’t include a built-in integration step for external deployment (e.g. Test Flight) — so deploying a finished archive to Test Flight is possible — but requires a custom post-integration script.

Is Xcode Server for you?

As always, the answer is: “maybe”. If the project you want to automate integration/testing/deployment for is targeting iOS or macOS, there’s really no reason not to try Xcode Server. It’s included with Xcode 10, and is a snap to setup and use.

Particularly if you’re new to CI/CD, you really can’t go wrong here — in the worst case you’ll get some experience with CI, probably cut down on some manual test/build work and better understand what features you need in a long-term solution if Xcode Server doesn’t fully meet your needs.

On the other hand, if you’re part of a fully-integrated cross-platform (e.g. iOS+Android) team that wants a unified solution for all development targets, Xcode Server might not be for you. While other solutions probably have a higher up-front learning curve and require more scripting to get going compared with Xcode Server, there are open source and commercial platforms that can provide cross-platform solutions where a unified CI/CD/Devops infrastructure is essential.

Related to This Post

Leave a Reply

Your email address will not be published. Required fields are marked *