Blame it on the internet gods (or probably Apple), but I have the hardest time downloading large (like gigabyte size) downloads from Apple’s servers. I’ve had problems when downloading iOS updates in iTunes and problems when downloading new simulators in XCode. After some long period of time trying to download a file, I get a “connection timed out” error. I try again. Same error. Try again. Same error.
Googling around I can tell that I am not alone. Others have the same problem and there really doesn’t seem to be a noticeable correlation to internet connection speed. This error even happens to users with “fast” connections.
Since I don’t know what is causing this error and I can’t fix anything on Apple’s servers, all I can do is find a work around. So if you are in a similar situation and for some reason need to download new iOS simulators outside of the normal XCode download process, here is how you do it.
These steps worked for me, on my machine, but your results may vary and Apple may change things tomorrow and break this whole process. So good luck.
Here are the specs for my setup:
Find the Download URL
The first thing you have to do is find the file that you need to download. To do this, open up XCode and click on “Preferences > Components” to see a list of available simulators to download.
Click the down arrow next to the simulator you want to download to begin the normal download process. In this example, I am downloading the iOS 9.3 Simulator.
Now open up your Console.app program and make sure you are looking at the “All Messages” tab. You might want to click the “Clear Display” to make the next step easier.
Once you are sure the simulator download has started in XCode, cancel it. When the download is cancelled, a new log will appear in Console with the url of the file that was being downloaded. This is the url for the file you want to manually download.
For my iOS 9.3 Simulator, the url was:
Download the Simulator Manually
Now that you have the url of the file, you can download it however you like. I chose to do it through Safari so I could easily see the progress and resume the download if needed. So I typed the url into the Safari address bar, pressed enter, and watched the bytes start flowing in.
You can just as easily download the file using curl on the command line. It doesn’t really matter how you get the file, just that you get the file.
Move the Downloaded File to the XCode Cache Directory
Thanks to Google translate and some nice Chinese speaking person, I was able to figure out the next step.
You need to locate the XCode cache directory on your computer. This will be under: ~/Library/Caches/com.apple.dt.Xcode
This cache directory isn’t a true “directory” and is instead a package. But we can still access it’s contents by right clicking on the file and clicking “Show Package Contents”.
Inside the cache directory you are looking for a folder called “Downloads”. When I first navigated into the cache directory, “Downloads” did not exist for me. So I created a new “Downloads” directory.
You need to place your downloaded simulator file into the “Downloads” directory. Make sure you have not changed the filename of the downloaded dmg file. It needs to match the filename of what appears in the original download url.
Install Simulator in XCode
Now we need to tell XCode that the file is ready to install. So go back to the simulator installation window in XCode by clicking on “Preferences > Components”. Click the download arrow next the simulator you are installing and you should see the progress bar move a lot faster this time. XCode is now using the manually downloaded file instead of downloading a new file from the Apple servers.
If all goes well, your simulator is now installed.