Building and testing iOS applications typically requires Xcode, which is only available on macOS. I faced this challenge myself a few years ago when I was studying mobile development and using Linux, without easy access to a Mac. At that time, I ended up giving up on the idea due to the difficulties. However, while recently browsing top repositories on GitHub, I came across an incredible project: a complete macOS Docker container with a graphical interface and a full macOS environment.
This guide is based on the macos-dockur project and walks you through the process of building and testing iOS apps using Docker.
Getting Started
The easiest and most common way to manage this type of container—especially since you’re likely to use it multiple times—is by utilizing Docker Compose. This simplifies the process and allows you to specify everything you need, like volumes, environment variables, and ports, in one file.
Here’s a sample docker-compose.yml file for this tutorial:
version: '3'
services:
macos:
image: dockurr/macos
environment:
VERSION: "15" # macOS version, we are using version 15 for better compatibility with Xcode
RAM_SIZE: "8G" # Recommended RAM size is at least 8GB
CPU_CORES: "4"
devices:
- /dev/kvm
cap_add:
- NET_ADMIN
volumes:
- ./storage:/storage # This folder will store your entire system
ports:
- 8006:8006 # Access the graphical interface via this port
- 5900:5900/tcp
- 5900:5900/udp
stop_grace_period: 2m
Running the Container
To start the container, simply use a simple docker-compose up
Once the container is running, you'll be able to access the macOS graphical interface by navigating to http://localhost:8006
in your browser after a few seconds.
Installing macOS
When the download finishes, you’ll be prompted with the system installer. The first thing you’ll need to do is format the disk. Open Disk Utility, find the largest "Apple Inc..." disk, and click “Erase.” You can go with the default settings.
Next, close Disk Utility and click "Reinstall macOS." Follow the installer prompts, using the default settings. At the final step, do not log in with your Apple ID—this setup runs more smoothly without it. The installation process will take some time (in my case, around 30 minutes), so be patient.
Installing Xcode
After the installation is complete, the first thing you’ll need to do is install Xcode. Since we don’t have access to the App Store with this setup, you’ll need to manually download Xcode from the Apple Developer website. Log in with your Apple ID in your browser and search for the Xcode version you want—in my case, I downloaded version 16.
Once the download finishes, follow these steps to install Xcode, you can install it by extracting in into the Applications folder
cd Downloads
xip -x Xcode_16.xip
sudo mv Xcode.app /Applications
Downloading the iOS Simulator
After Xcode is successfully installed, you can open it and begin developing your iOS applications. You’ll be able to compile and test them using Xcode’s built-in simulator.
To download the IOS simulator, you'll need to open xcode and select to create a new iOS project, click to download the iOS simulator in the current iOS version.
Running the Simulator
After the download have been finished, you can open the simulator normally by going in the menu Xcode > Open Developer Tool > Simulator and test whatever you want.
A Heads-up About Performance
It’s important to mention that the Simulator will likely run waaaay slowly in this setup. While it may not be the fastest experience, for someone without access to a Mac, this method still provides a functional environment to develop and test iOS apps. It's not perfect, but it's definitely workable.
Top comments (0)