12

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 & 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>
  ▿ 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
"iOS"

Looks like this issue still exists. Is there a way I could fix this to work on latest Xcode version?

Sasi
  • 1,666
  • 2
  • 24
  • 44

4 Answers4

14

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>.

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>/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

Then:

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...>
  • 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

Arguments

  • switch to the tab 'Options'
  • enter as `Working Directory' the path where the Cartfile resides

Workding Directory

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:

Debug Session

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!

Sasi
  • 1,666
  • 2
  • 24
  • 44
Stephan Schlecht
  • 26,556
  • 1
  • 33
  • 47
  • 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. – Sasi Jan 05 '19 at 15:29
  • Can you post one device from `xcrun simctl list devices --json`? – Stephan Schlecht Jan 05 '19 at 16:07
  • Updated my question. Please take a look. – Sasi Jan 05 '19 at 17:54
  • 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? – Stephan Schlecht Jan 05 '19 at 18:56
  • Tried removing cache as you mentioned. But dint fix the issue. – Sasi Jan 06 '19 at 06:32
  • 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..... – Stephan Schlecht Jan 06 '19 at 12:34
  • 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). – Sasi Jan 07 '19 at 07:27
  • 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)) – Stephan Schlecht Jan 07 '19 at 12:28
  • 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 – Sasi Jan 07 '19 at 15:57
  • 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? – Stephan Schlecht Jan 07 '19 at 16:25
  • 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. – Sasi Jan 07 '19 at 16:26
  • 1
    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. – Stephan Schlecht Jan 08 '19 at 22:34
  • Finally it is working after 'make install'. Thanks you very much. Im accepting your answer. – Sasi Jan 11 '19 at 14:40
  • Awesome explanation!! – Jayprakash Dubey Jan 25 '19 at 10:36
4

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

veladan
  • 365
  • 1
  • 4
  • 11
2

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

Ender
  • 21
  • 2
  • I faced the same issue after upgrading to Xcode10.3. Updating Carthage worked like a charm. Thanks!! – Tarun Sep 05 '19 at 07:00
1

Try installing a previous version of carthage

brew install carthage 0.30.1

Carlos Chaguendo
  • 2,895
  • 19
  • 24