May 15, 2017 - Achilleas Pipinellis    

How to use GitLab CI and MacStadium to build your macOS or iOS projects

Learn how to use GitLab CI on MacStadium's mini servers to build your macOS or iOS projects.

In this article, we will see how to get started with MacStadium, a provider that offers dedicated Mac hardware which you can use with GitLab CI and build your macOS or iOS application.

Continuous Integration and Delivery with GitLab is easier if you are developing your application on Linux. All you need to do is find a provider, spin up a VM, install GitLab Runner on it and configure your project's .gitlab-ci.yml file. On macOS on the other hand, things may not be that easy. Finding a provider that offers a Mac machine that will be online 24/7 can be hard. MacStadium is here to help achieve that goal and offers a discount to all GitLab users. Let's see how to make this happen.


On this page


Choosing a Mac mini plan

The first step is to choose a plan. MacStadium offers many options, so you can pick whatever fits your needs. A Mac mini is perfect to test things out and is a good first choice. It should be enough to get you started, but depending on your needs you may have to upgrade to a more beefy machine.

Depending on your location and project needs, you have to:

  1. Choose the datacenter
  2. Choose the Mac mini
  3. Choose the macOS version
  4. Click Start Trial (24 hours) on the Mac mini of your choice to get going in a few steps

At first you'll be asked to create a MacStadium account Fill in your information and when in the Secure Checkout page, be sure to check the I want to use a coupon code option and use GITLAB10 for 10% off.

At the time of this writing, the staged machines come with macOS 10.12.2. As new releases com from Apple, MacStadium tests them thoroughly and then update their staged machines. Of course, as a customer you can run the OS update on your own machine anytime.

Connecting to the Mac mini

When you sign up, you'll receive an email with two important pieces of information:

  1. The static IP address of your Mac. This will allow you to find your Mac mini from anywhere in the world, and you can also point domain names to this IP address so it's easier to remember.

  2. The username and password to access the machine. The user is standard for all installs, but the password is randomly generated. Upon the first login, you can and are encouraged to change it.

After you have this information, there are two ways of connecting to your Mac mini: VNC and SSH.

Connecting with VNC

If connecting from a Mac, Apple's Screen Sharing is ideal. It's installed on every Mac and can you can connect on your MacStadium Mac mini easily with the username and password that was sent to you via email.

If you don't have a favorite VNC client already, there are a number of options to choose from:

When you connect with VNC, you can use the same password that is setup for the user on the Mac mini.

macOS has that as a separate setting, but MacStadium's provision scripts enable VNC connections by default.

Connecting with SSH

You can SSH into your machine using the username and password. For example, if the username is administrator and the IP address of your machine 1.2.3.4:

ssh administrator@1.2.3.4

Enter the password when asked (you won't be able to see it), hit Enter and you're in!

Setting up the development environment

The following steps are to be performed to the remote Mac machine. We need to install Xcode and the command line tools that contain the SDKs and UNIX development applications like the LLVM compiler, etc.

Apart from the needed toolset, the screensaver needs to be disabled otherwise the machine will be put to sleep, thus disrupting the workflow of CI. Thankfully, all the machines hosted on MacStadium are set to never sleep by default. It's just done in System Preferences > Energy Saver.

Installing Xcode

There are two ways to install Xcode. You can either download it from Apple's developer portal or use the App Store where you might be asked to fill in your credit card information. To avoid that, manually download Xcode:

  1. Connect via VNC to the remote Mac machine
  2. Open a browser and go to https://developer.apple.com/download/more
  3. Login with your existing AppleID or create one
  4. Select the Xcode version you wish to install

    Download latest stable Xcode

    This should download the Xcode package in your Downloads folder and decompress it automatically. After a couple of minutes it should finish.

  5. Open a terminal and move Xcode.app to /Applications so that it can be found by Launchpad:

    mv ~/Downloads/Xcode.app /Applications
    
  6. Go to your Applications, and double click on Xcode in order to install it. The verification will begin, that should take a minute.
  7. Answer "Open" when you are asked if you are sure you want to open it.
  8. Select "Agree" in the License Agreement and provide your administrator password.
  9. The installation process should begin and after a while you will have Xcode installed and ready to be used.

In the next step we will install the command line developer tools.

Installing the command line tools

The command line tools are a subsection of Xcode, so if you installed Xcode, you may skip this part.

  1. Open the Terminal app or run this command via SSH:

     xcode-select --install
    
  2. Accept the License Agreement and the installation will begin


Now that all development tools are installed, it's time to install GitLab Runner.

Installing and configuring the GitLab Runner

GitLab Runner is responsible for running your jobs in macOS and then it reports the results back to GitLab.

To install it, follow the instructions in the Runner's documentation. Make sure to also carefully read the current limitations.

Testing a project with CI

The final piece of this puzzle is to set up a project in GitLab (your own CE/EE instance or even GitLab.com) and hook it up with Mac mini. We will not expand on that, but you can follow this nice blog post by Angelo Stavrow on Setting up GitLab CI for iOS projects. It includes comprehensive steps to get you started.

Conclusion

Having a dedicated Mac machine for your development can save you precious time when you follow the Continuous Integration workflow with your team. In this tutorial, you've seen how to quickly get a remote Mac mini up and running for your needs. Be sure to add the promo code GITLAB10 on checkout for 10% off!

Happy building!


Get 10% off of all MacStadium plans by using GITLAB10 at checkout. The coupon can only be applied when signing up hardware, but if you are an existing customer who is using Gitlab and makes a change in hardware, you can always apply it again or request the discount in a ticket.


Cover image provided by MacStadium.

For the latest and most detailed news follow @gitlab on Twitter. Future blog posts suggestions RSS

Install GitLab in 2 minutes

With Ubuntu, Debian, CentOS, openSUSE, and Raspbian packages or from source

Install GitLab Now

Try GitLab Enterprise Edition risk-free for 30 days.

No credit card required. Have questions? Contact us.