ios-control / ios-sim

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

"Cannot convert undefined or null to object" after running `ios-sim showsdks` #220

Closed kelvindart closed 7 years ago

kelvindart commented 7 years ago

Expected behavior

To be able to call the command without error, and have it return data listing installed SDKs.

Actual behavior.

Currently when you run the following command via ios-sim, it displays the error you see beneath the command:

$ ios-sim showsdks
Cannot convert undefined or null to object

Steps to reproduce the problem

  1. Run ios-sim showsdks.
  2. Observe error.

System Specs

Please run the commands below in your Terminal.app and include it in the issue. Check when done and include results below.

system_profiler SPSoftwareDataType

    System Software Overview:

      System Version: macOS 10.12.6 (16G29)
      Kernel Version: Darwin 16.7.0
      Boot Volume: Macintosh HD
      Boot Mode: Normal
      Computer Name: Kelvin’s MacBook Pro
      User Name: Kelvin Dart (kelvindart)
      Secure Virtual Memory: Enabled
      System Integrity Protection: Enabled
      Time since boot: 2 days 8:18

ios-sim --version

6.1.1

xcodebuild -version

Xcode 9.0
Build version 9A23

xcode-select --print-path

/Applications/Xcode.app/Contents/Developer

node --version

8.5.0
kelvindart commented 7 years ago

I have just debugged this. The issue is because of the following line: https://github.com/phonegap/ios-sim/blob/master/src/lib.js#L329

list = fixSimCtlList(list);

The call to fixSimCtlList(...) is unrequired. This references two properties in regards to the simulators: devicetypes and devices. We are concerned with the SDKs, not simulators at this point, so the call is unnecessary; list is of the following format:

{
  "runtimes": [
    {
      "buildversion": "15A372",
      "availability": "(available)",
      "name": "iOS 11.0",
      "identifier": "com.apple.CoreSimulator.SimRuntime.iOS-11-0",
      "version": "11.0"
    },
    {
      "buildversion": "15J380",
      "availability": "(available)",
      "name": "tvOS 11.0",
      "identifier": "com.apple.CoreSimulator.SimRuntime.tvOS-11-0",
      "version": "11.0"
    },
    {
      "buildversion": "15R372",
      "availability": "(available)",
      "name": "watchOS 4.0",
      "identifier": "com.apple.CoreSimulator.SimRuntime.watchOS-4-0",
      "version": "4.0"
    }
  ]
}

I will raise a PR, and reference this bug.

shazron commented 7 years ago

Fixed in #221