Title: Carthage update failure saying "Could not find any available simulators for iOS" - Xcode 10.1, macOS Mojave (10.14.2)
Tags: ios;swift;realm;carthage;xcode10.1
Question: I am trying to install Realm to my project using Carthage. It used to work before but after switching to new MacBook Pro (15-inch, 2018, TouchBar) I am getting the following error,
carthage update --no-use-binaries --platform iOS
*** Fetching realm-cocoa
*** Checking out realm-cocoa at "v3.13.0"
*** xcodebuild output can be found in /var/folders/m4/1z0tvn6d67q2rqwcjvndy80m0000gn/T/carthage-xcodebuild.2vfx4v.log
*** Building scheme "Realm" in Realm.xcworkspace
Could not find any available simulators for iOS
I have tried uninstalling &amp; reinstalling Carthage (0.31.2) and followed the steps given in these answers,
Stack Overflow Question
Carthage Git Issue
Carthage Fix and Release
xcrun simctl list devices --json
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPad Pro",
"udid" : "94790E33-EA0A-40B4-BA0A-19CC8D976A6F",
"availabilityError" : ""
}
Debug Carthage
(lldb) po devices[latestOSName]?.first { $0.isAvailable }
▿ Optional<Simulator&gt;
▿ some : Simulator
- isAvailable : true
- name : "iPhone 5s"
- udid : 87A9C887-034C-44A8-8F30-C90AF9ACCBCC
(lldb) po sdk.platform
XCDBLD.Platform.iOS
(lldb) po sdk.platform.rawValue
Looks like this issue still exists. Is there a way I could fix this to work on latest Xcode version?
Comment: Do you need to set **Command Line Tool?**

Comment: @SasiM are you using any pre-built SDK. if you are using Realm pre-build for device or simulator make sure using correct one.

Comment: @iDeveloper I already set that but no change. Still getting the same error.

Comment: @duncanc4 using 0.31.2 only. Even tried uninstalling and installing it again. But dint fix the issue.

Comment: @PranavanSp no im not. I am using latest release from Realm not pre-build.

Comment: Upgrading Carthage to 0.31.2 fixed the issue for me.

Here is the accepted answer: Perhaps some checks you can make to narrow it down a little bit:
Carthage version
carthage version
should output
0.31.2
Multiple Xcode installed
xcode-select -p
should give
/Applications/Xcode.app/Contents/Developer
for a standard installation.
Simulator
xcrun simctl list devices --json
That should output a list like:
"devices" : {
"iOS 12.1" : [
{
"availability" : "(available)",
"state" : "Shutdown",
"isAvailable" : true,
"name" : "iPhone 5s",
"udid" : "1A6959A0-C10F-474B-96C5-7E8955FBDD80",
"availabilityError" : ""
},
If there are no simulators add one using Xcode <Window/Devices and Simulators&gt;.
If there are entries please check if there is a 'isAvailable' entry with true as value:
"isAvailable" : true,
If not, check Xcode installation.
Remove Caches
One could als try to
quit Xcode
remove caches for Carthage and Xcode derived data folder
As always when using rm -rf you have to be careful:
rm -rf ~/Library/Caches/org.carthage.CarthageKit
rm -rf <your project folder&gt;/Carthage
xcrun simctl delete unavailable
Then try again:
carthage update --no-use-binaries --platform iOS
Debug Carthage
The nice thing about Carthage is that it is open source and even written in Swift.
So to debug it we can:
quit Xcode
create a folder in Terminal and cd to the folder
git clone https://github.com/Carthage/Carthage.git
cd Carthage
git checkout 0.31.2
make bootstrap
open Carthage.xcworkspace
Afterwards we need to enter command line arguments. To do so:
in Xcode use <Product/Scheme/Edit Scheme...&gt;
on the left choose 'Run/Debug'
on the right choose tab 'Arguments'
change the 'Arguments Passed on Launch' to update --no-use-binaries --platform iOS
switch to the tab 'Options'
enter as `Working Directory' the path where the Cartfile resides
Finally:
open Carthage/Source/CarthageKit/Simulator.swift
set breakpoints in the method selectAvailableSimulator
Then you can debug what's going wrong.
If everything is fine it would look like this:
If no error occurred when run from Xcode then let it run in Xcode completely without breakpoint and giving it some time to do the compile.
If carthage update is successful from Xcode project then uninstall your current carthage installation as described here.
How to uninstall Carthage from OS X?
Then in Terminal go to the Carthage project folder where the Makefile resides and type:
'make install'
Afterwards you can try it from the command line again. It should work!
Comment for this answer: Can you post one device from `xcrun simctl list devices --json`?
Comment for this answer: Ok, I added instructions for removing caches - worth a try. After calling `carthage update...` there should be a new folder in ~/Library/Caches/org.carthage.CarthageKit/DerivedData again. What is the name of this folder?
Comment for this answer: Ok, we have one last option: Since Carthage is an open source project which was even developed in Swift, we can debug it relatively easily, I have added detailed instructions in my answer above. I am curious.....
Comment for this answer: it might be easier to show it in a screencast, where I show the steps as described above - here a link to a screencast  with less then 3 minutes: https://www.software7.biz/iertzighbvldhzh/carthagedebug.mp4 (btw: in between you need to be patient, even if Carthage is called from the command line, it still takes some time with complex projects (e.g. realm))
Comment for this answer: Interesting: so no error when run from Xcode. If you just run it in Xcode completely (without breakpoint and giving it some time to do the compile) does it work then?
Comment for this answer: So from Xcode project it is working. You could now uninstall your current carthage installation (perhaps even using both methods described here: https://stackoverflow.com/a/48040795/2331445). Then in Terminal go to the Carthage project folder (where the Makefile resides) and type: 'make install'. Afterwards you can try it from the command line again.
Comment for this answer: Awesome explanation!!
Comment for this answer: Yes I made sure all of these were correct before posting this question. Even tried uninstalling Xcode 10.1 and installed Xcode 10 but it dint fix the problem still.
Comment for this answer: Updated my question. Please take a look.
Comment for this answer: Tried removing cache as you mentioned. But dint fix the issue.
Comment for this answer: I have set everything as you said but not sure how to debug it. When I try to run the Carthage it says Build failure with no error message (10 warnings).
Comment for this answer: I have followed the steps shown in the video and able to run Carthage workspace. The result is,
po devices[latestOSName]?.first { $0.isAvailable }
▿ Optional
▿ some : Simulator
- isAvailable : true
- name : "iPhone 5s"
- udid : 87A9C887-034C-44A8-8F30-C90AF9ACCBCC
Comment for this answer: Yes no error from Xcode. It is building the schemes with no issues. But wonder why it is not the same when I run from Terminal.
Comment for this answer: Finally it is working after 'make install'. Thanks you very much. Im accepting your answer.

Here is another answer: I solved this same problem upgrading Carthage 0.31.2 to 0.33.0 with:
brew upgrade carthage
PS: Problem occurred after updating Xcode to version 10.2
Comment for this answer: I faced the same issue after upgrading to Xcode10.3. Updating Carthage worked like a charm. Thanks!!

Here is another answer: Try installing a previous version of carthage
brew install carthage 0.30.1

Here is another answer: I solved this same problem upgrading Carthage to version 0.32.0 with:
brew upgrade carthage
PS: Problem occurred after updating Xcode to version 10.2

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 4, 'CommentCount': 6, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2019:00:01/03/19', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<ios><swift><realm><carthage><xcode10.1>', 'Title': 'Carthage update failure saying "Could not find any available simulators for iOS" - Xcode 10.1, macOS Mojave (10.14.2)', 'ViewCount': 4273, 'id': 54017424, 'user_AboutMe': '<p>Loving Father | Caring Husband | Avid Programmer | Mobile Geek | iOS for Passion | Travel / Photography / Movies / Series for Fun | Family for Life |</p>\n', 'user_AccountId': 1496962.0, 'user_DisplayName': 'Sasi', 'user_Reputation': 1567.0, 'user_Views': 211.0, 'user_id': 1402675.0}}