Fix Xcode losing references to downloaded Simulator runtimes

May 06, 20243 min read#xcode, #simulator, #swift

Recent versions of Xcode have changed how they manage Simulator runtimes. The Xcode binaries become smaller because users will have to download Simulator Runtimes separately after starting Xcode for the first time. The Simulator Runtimes are stored as Disk Images (dmg files) and will be mounted and accessed by Xcode when needed.

issue

The issue is that, sometimes, Xcode can’t recognise those mounted runtimes and force users to download them again.

This seems to be a widespead issue, acknowledged by Apple as well.

Our team at my job has been facing this issue for quite some times, and we couldn’t find the reason why the Simulator Runtimes keep unmounted.

🟢 Final Solution:

It looks like that Apple has finally fixed the root cause of the issue. Following this post, you can download the latest version of XProtect, which will not mistakenly recognise the Simulator Runtimes Disks as malware 🤷🏻‍♂️.

I still keep the old post for references.


We have found multiple solutions to fix this issue that I will list out here.

Solution 1: Simple, but slow

Restart your Mac 😁. Yes, it’s true, recommended by Apple as well.

Solution 2: No Restart, but require sudo permission

Run the following shell command:

sudo killall -9 http://com.apple.CoreSimulator.CoreSimulatorService

Solution 3: Robust solution

We will copy the Simulator runtime from the separate dmg image to the Runtime folder inside the Xcode.app. With this, the Simulator runtime will be loaded directly from the local disk, without mounting the corresponding dmg image.

Step 1:

Download the corresponding iOS Simulator Runtime DMG from Apple website.

runtime download

After downloading you should be able to open the iOS 17.4 Simulator Runtime.dmg and see the runtime file iOS 17.4.simruntime inside the disk image.

Step 2:

Create a Runtimes folder inside your Xcode.app ‼️

sudo mkdir /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Runtimes

Step 3:

Copy the Simulator Runtime into the Xcode.app. After this step, you should have the runtime file at this path: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Runtimes/iOS 17.4.simruntime

After this step, restart your Xcode and it should work. My Xcode doesn’t lose references to the Simulator Runtime anymore. Xcode should have permanent access to the Simulator runtime directly, without mounting any dmg file.

xcode

Quick Drop logo

Profile picture

Personal blog by An Tran. I'm focusing on creating useful apps.
#Swift #Kotlin #Mobile #MachineLearning #Minimalist


© An Tran - 2024