83

Can I run Xcode in a docker container? I'd like to dockerise an Xcode CI system, just wondering if this is possible.

Chris
  • 39,719
  • 45
  • 189
  • 235

3 Answers3

38

This answer is now likely to be out of date as it was written in 2015. It may still be useful as reference to reproduce the same

--

This repo from Docker Hackathon 2015 describes how to build and run iOS apps with the docker client. Is that what you're after?

Watch the video:

Secret sauce is in server.js that implements a REST API to simulate a docker server. So in fact it's not actually running iOS in a real Linux docker server - rather it implements the docker API and then acts as a proxy to ios-sim (run) and XCode (build).

Tony O'Hagan
  • 21,638
  • 3
  • 67
  • 78
  • Certainly looks really interesting! – Chris Jul 18 '15 at 11:03
  • 25
    I don't believe this achieves what the original question was about? My interpretation was that @Chris was hoping to migrate his unit test / build setup from a (presumably OSX machine-based) continuous integration server to a Docker-based CI system (such as Bitbucket Pipelines?). My use case is just that: Bamboo hosted on OSX machine -> Bitbucket Pipelines. – Johnus Jul 06 '16 at 05:59
  • 2
    I'm not successful in implementing this. It uses XCode image which I am not sure where it gets from since it is not in Docker libraries. – Vimalraj Selvam Jul 30 '16 at 05:42
  • What this does: they created a docker registry server that can receive a Dockerfile and then call xcodebuild (that should be locally installed). The advantages of Docker (containers that can be configured, spawned and thrown away after usage) are not used this way (unfortunately). (Although this is a very creative way to run xcodebuild :-) ) – raoel Feb 14 '17 at 19:50
  • 6
    I don't think this is a valid answer. The author of the repo himself says [here](https://github.com/jkingyens/docker4xcode/issues/1) that >The xcode:7.0 docker image is **not actually a docker image**. In this case Xcode:7.0 just tells the build tools to build using xcode 7 on OSX platform. This base "image" is basically the existing development environment on your mac. I wanted to make it look like a traditional dockerfile as much as possible (and match the concepts). – Mig82 Mar 12 '18 at 14:48
  • So that means if you set up a hackintosh - you can use said Docker Image with that secret sauce. Somebody tell me if this won't work, pls :-) – Lenny Feb 28 '19 at 14:46
  • This code was written in 2015 and it's likely that the Docker API has now moved on. – Tony O'Hagan Aug 28 '19 at 23:13
  • It seems that the base image is missing for that. – D4NT3 Jul 22 '22 at 09:45
10

Look at Docker-OSX which runs macOS with Xcode support inside Docker.

You can connect to that macOS via SSH or VNC and use Xcode on Linux

Alex Kosh
  • 2,206
  • 2
  • 19
  • 18
5

Circle CI has an option to use Xcode in a container. Here is an excerpt of my ci pipleline config:

ios-build-env: &ios-build-env
  macos:
    xcode: "11.4.1"

jobs:
  ios-deploy:
    <<: *ios-build-env
    steps:
    - checkout
    ...

Circles docs: https://circleci.com/docs/2.0/testing-ios/

Jared Anderton
  • 826
  • 9
  • 12