Provisioning a Mac OS X system for iOS CI

Make sure you take a look at the intro article first.

Two ground rules — you must legally use Apple-branded hardware. This is a requirement in the terms of service of Mac OS X. Also, you may only run two instances of Mac OS X per piece of hardware. As mentioned in the intro article, you can find out more about the Terms of Service (for El Capitan) here. The particular sections I’ve mention above are in the title “SOFTWARE LICENSE AGREEMENT FOR OS X EL CAPITAN For use on Apple-branded Systems” and section 2Biii.

This tutorial was written for developing a CI system using Packer and VMWare. While these scripts may work on other systems, some of them may not. However, I’ll make note where Packer and VMWare come into play so you can modify the code presented for other environments.

We will walk through three important aspects in the overall system.

System Setup

This script will setup the Mac system for use in a headless environment.

  • As we’ll be running developer tools, we need to enable them.
  • Spotlight, screensavers, and a number of animations can slow down and cause the system to use unnecessary resources that would otherwise be used by the CI processes, so we disable these.
  • We will also tell the hard drives to never sleep as that would mean the system would not be available when we would need it (for example in the early morning after not being used all night).
  • We set some default names for the system to ensure the system readable, identifiable, and easily accessible.
  • We install any available updates (without iTunes because it’s massive) as we disable automatic updates. We disable the updates because we can’t have the system restarting to finish an update or resources used where they aren’t needed.

You’ll need to enable a few options for the system to function ideally. We assume you are using Packer and VMWare here as “VM_NAME” is assumed to be set as a variable at the top of the script.

Custom SSHD client

Macs often have difficulty in communicating and interacting with GUI-based systems using the default SSH clients. Using a Mac OS Launch agent, we can install and start a custom SSHD host which will help fix the issue interacting with GUIs.

Take the file below and execute it with this command: “/bin/bash customsshd install”

Network Detection Script

Due to some issues with running in a headless, virtualized environment, sometimes network devices may not work correctly. This script uses a Mac OS Launch Daemon which runs at system launch that will re-detect any attached network interfaces.

Simply run this script to install.

VMWare Tools

This will provide you insight into the Mac and allow you to get various pieces of information — like the VM’s (Mac’s) IP Address.

That takes care of the first steps for provisioning a Mac OS X system for use in an iOS CI compute cluster. After this, you should have the Mac system setup with various setting enabled and others disabled, an SSH fix for interacting with GUI, a network detection fix for network devices, and VMWare tools installed.

If you have any questions or suggestions, share them with me in the comments. Next, we’ll go over Xcode, iOS SDKs, and iOS Simulators for CI Systems.