ios-control / ios-sim

Command-line application launcher for the iOS Simulator
Apache License 2.0
1.49k stars 253 forks source link

No devices in cordova project #246

Closed ejerskov closed 5 years ago

ejerskov commented 5 years ago

ios-sim showdevicetypes

Expected behavior

The available devices from Xcode

Actual behavior.

Empty list

System Specs

System Software Overview:

  System Version: macOS 10.14.3 (18D109)
  Kernel Version: Darwin 18.2.0
  Boot Volume: Macintosh HD
  Boot Mode: Normal
  Computer Name: ---
  User Name: ---
  Secure Virtual Memory: Enabled
  System Integrity Protection: Enabled
  Time since boot: 7 days 17:09

  ios-sim version
  7.0.0

  xcodebuild -version
  Xcode 10.1
  Build version 10B61

  xcode-select --print-path
  /Applications/Xcode.app/Contents/Developer

  node --version
  v10.15.1
shazron commented 5 years ago

Should be fixed in v8.0 (upcoming release)

ejerskov commented 5 years ago

Thank you for the quick respons @shazron ! Any ETA on v8.0? Or can I manually downgrade to get it to work until?

shazron commented 5 years ago

Already released.

ejerskov commented 5 years ago

Hi @shazron I've just updated by running npm install -g ios-sim

ios-sim --version returns 8.0.0

But ios-sim showdevicetypes still returns an empty list

Im I doing something wrong?

davlhd commented 5 years ago

The problem is the output of xcrun simctl list --json:

Thats a runtime:

  "runtimes" : [
    {
      "bundlePath" : "\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS 11.3.simruntime",
      "availabilityError" : "",
      "buildversion" : "15E217",
      "availability" : "(available)",
      "isAvailable" : true,
      "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-11-3",
      "version" : "11.3",
      "name" : "iOS 11.3"
    },

Those are devices:

  "devices" : {
    "iOS 12.1" : [
      {
        "availability" : "(available)",
        "state" : "Shutdown",
        "isAvailable" : true,
        "name" : "iPhone 5s",
        "udid" : "DA69902D-B4FC-46E3-9465-D48D0C04B5BB",
        "availabilityError" : ""
      },

vs.

 "devices" : {
    "com.apple.CoreSimulator.SimRuntime.iOS-11-4" : [
      {
        "availability" : "(unavailable, runtime profile not found)",
        "state" : "Shutdown",
        "isAvailable" : false,
        "name" : "iPhone 5s",
        "udid" : "43416A47-F7D3-4F57-8729-776F22323D88",
        "availabilityError" : "runtime profile not found"
      },

findRuntimesGroupByDeviceProperty tries to find the runtimes by using the name property. In the second case it's not grouped by the name its grouped by identifier.

I do not know enough about this project to create a PR. But a quick fix is to change the findRuntimesGroupByDeviceProperty function inside /usr/local/lib/node_modules/ios-sim/src/lib.js

from available_runtimes[ runtime.name ] = (runtime.availability === '(available)'); to available_runtimes[ runtime.identifier] = (runtime.availability === '(available)');

David

Edit: Just for clarity: the second device comes from a different machine that groups them by identifier. They use 2 different Xcode versions.

ejerskov commented 5 years ago

Thanks @davlhd!

With your fix I now get a list of devices when running ios-sim showdevicetypes. However, when I run ionic cordova emulate ios --list I still get an empty list - do you know why? I have tried to remove and add the ios platform afterwards.

shazron commented 5 years ago

Hmm I'm getting the right devices with ios-sim 8. However I don't have iOS 11 Sims installed maybe that's why:

$ ios-sim showdevicetypes
Apple-TV-1080p, tvOS 12.1
Apple-TV-4K-4K, tvOS 12.1
Apple-TV-4K-1080p, tvOS 12.1
Apple-Watch-Series-2-38mm, watchOS 5.1
Apple-Watch-Series-2-42mm, watchOS 5.1
Apple-Watch-Series-3-38mm, watchOS 5.1
Apple-Watch-Series-3-42mm, watchOS 5.1
Apple-Watch-Series-4-40mm, watchOS 5.1
Apple-Watch-Series-4-44mm, watchOS 5.1
iPhone-5, 10.3
iPhone-5, 9.3
iPhone-5s, 10.3
iPhone-5s, 12.1
iPhone-5s, 9.3
iPhone-6, 10.3
iPhone-6, 12.1
iPhone-6, 9.3
iPhone-6-Plus, 10.3
iPhone-6-Plus, 12.1
iPhone-6-Plus, 9.3
iPhone-6s, 10.3
iPhone-6s, 12.1
iPhone-6s, 9.3
iPhone-6s-Plus, 10.3
iPhone-6s-Plus, 12.1
iPhone-6s-Plus, 9.3
iPhone-7, 10.3
iPhone-7, 12.1
iPhone-7-Plus, 10.3
iPhone-7-Plus, 12.1
iPhone-SE, 10.3
iPhone-SE, 12.1
iPad-Air, 10.3
iPad-Air, 12.1
iPad-Air, 9.3
iPad-Air-2, 10.3
iPad-Air-2, 12.1
iPad-Air-2, 9.3
iPad--5th-generation-, 10.3
iPad--5th-generation-, 12.1
iPad-Pro--9-7-inch-, 10.3
iPad-Pro, 10.3
iPad-Pro--12-9-inch---2nd-generation-, 10.3
iPad-Pro--12-9-inch---2nd-generation-, 12.1
iPad-Pro--10-5-inch-, 10.3
iPad-Pro--10-5-inch-, 12.1
iPhone-8, 12.1
iPhone-8-Plus, 12.1
iPhone-X, 12.1
iPad-Pro--9-7-inch-, 12.1
iPad-Pro--9-7-inch-, 9.3
iPad-Pro, 12.1
iPad-Retina, 9.3
iPad--6th-generation-, 12.1
iPhone-XS, 12.1
iPhone-XS-Max, 12.1
iPhone-XR, 12.1
iPad-Pro--11-inch-, 12.1
iPad-Pro--12-9-inch---3rd-generation-, 12.1
iPhone-4s, 9.3
iPad-2, 9.3

Note that ionic/cordova bakes in a version of ios-sim that might be older.

shazron commented 5 years ago

Added the iOS 11.4 simulator, I still can't repro the problem, output seems normal:

$ ios-sim showdevicetypes
Apple-TV-1080p, tvOS 12.1
Apple-TV-4K-4K, tvOS 12.1
Apple-TV-4K-1080p, tvOS 12.1
Apple-Watch-Series-2-38mm, watchOS 5.1
Apple-Watch-Series-2-42mm, watchOS 5.1
Apple-Watch-Series-3-38mm, watchOS 5.1
Apple-Watch-Series-3-42mm, watchOS 5.1
Apple-Watch-Series-4-40mm, watchOS 5.1
Apple-Watch-Series-4-44mm, watchOS 5.1
iPhone-5, 10.3
iPhone-5, 9.3
iPhone-5s, 10.3
iPhone-5s, 12.1
iPhone-5s, 9.3
iPhone-5s, 11.4
iPhone-6, 10.3
iPhone-6, 12.1
iPhone-6, 9.3
iPhone-6, 11.4
iPhone-6-Plus, 10.3
iPhone-6-Plus, 12.1
iPhone-6-Plus, 9.3
iPhone-6-Plus, 11.4
iPhone-6s, 10.3
iPhone-6s, 12.1
iPhone-6s, 9.3
iPhone-6s, 11.4
iPhone-6s-Plus, 10.3
iPhone-6s-Plus, 12.1
iPhone-6s-Plus, 9.3
iPhone-6s-Plus, 11.4
iPhone-7, 10.3
iPhone-7, 12.1
iPhone-7, 11.4
iPhone-7-Plus, 10.3
iPhone-7-Plus, 12.1
iPhone-7-Plus, 11.4
iPhone-SE, 10.3
iPhone-SE, 12.1
iPhone-SE, 11.4
iPad-Air, 10.3
iPad-Air, 12.1
iPad-Air, 9.3
iPad-Air, 11.4
iPad-Air-2, 10.3
iPad-Air-2, 12.1
iPad-Air-2, 9.3
iPad-Air-2, 11.4
iPad--5th-generation-, 10.3
iPad--5th-generation-, 12.1
iPad--5th-generation-, 11.4
iPad-Pro--9-7-inch-, 10.3
iPad-Pro, 10.3
iPad-Pro--12-9-inch---2nd-generation-, 10.3
iPad-Pro--12-9-inch---2nd-generation-, 12.1
iPad-Pro--12-9-inch---2nd-generation-, 11.4
iPad-Pro--10-5-inch-, 10.3
iPad-Pro--10-5-inch-, 12.1
iPad-Pro--10-5-inch-, 11.4
iPad-Retina, 9.3
iPhone-8, 12.1
iPhone-8, 11.4
iPhone-8-Plus, 12.1
iPhone-8-Plus, 11.4
iPhone-X, 12.1
iPhone-X, 11.4
iPad-Pro--9-7-inch-, 12.1
iPad-Pro--9-7-inch-, 9.3
iPad-Pro--9-7-inch-, 11.4
iPad-Pro, 12.1
iPad-Pro, 11.4
iPad--6th-generation-, 12.1
iPhone-XS, 12.1
iPhone-XS-Max, 12.1
iPhone-XR, 12.1
iPad-Pro--11-inch-, 12.1
iPad-Pro--12-9-inch---3rd-generation-, 12.1
iPhone-4s, 9.3
iPad-2, 9.3
replicadse commented 5 years ago

I have the exact same behaviour as @ejerskov . I also get all the devices using 'ios-sim showdevicetypes' but get not device using 'cordova run ios --list'.

shazron commented 5 years ago

This is fixed in ios-sim@8.0.1. cordova-ios has been updated to use the latest ios-sim but it needs a patch release that includes the fix, or you can install the nightly: cordova platform add ios@nightly