ios-control / ios-sim

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

TypeError: Cannot read property 'devicetypes' of undefined #268

Open hershko opened 4 years ago

hershko commented 4 years ago

I'm getting the following message when running "ios-sim showdevicetypes":

TypeError: Cannot read property 'devicetypes' of undefined at fixSimCtlList (/usr/local/lib/node_modules/ios-sim/src/helpers.js:12:38) at getDeviceTypes (/usr/local/lib/node_modules/ios-sim/src/helpers.js:30:10) at ShowDeviceTypesCommand.run (/usr/local/lib/node_modules/ios-sim/src/commands/showdevicetypes.js:7:25) at ShowDeviceTypesCommand._run (/usr/local/lib/node_modules/ios-sim/node_modules/@oclif/command/lib/command.js:44:31) Assafs-MacBook-Pro:ReleaseForRunning-iphonesimulator hershko$ ios-sim showdevicetypes TypeError: Cannot read property 'devicetypes' of undefined at fixSimCtlList (/usr/local/lib/node_modules/ios-sim/src/helpers.js:12:38) at getDeviceTypes (/usr/local/lib/node_modules/ios-sim/src/helpers.js:30:10) at ShowDeviceTypesCommand.run (/usr/local/lib/node_modules/ios-sim/src/commands/showdevicetypes.js:7:25) at ShowDeviceTypesCommand._run (/usr/local/lib/node_modules/ios-sim/node_modules/@oclif/command/lib/command.js:44:31)

In case it helps: The ios-sim version is "ios-sim/9.0.0 darwin-x64 node-v13.11.0". Node version is "v13.11.0". macOS Catalina, Xcode 11.3.1.

Thanks :)

omegayal commented 4 years ago

Maybe you can check whether the command line tool for Xcode is specified: Xcode -> Preference -> Locations -> Command Line Tools. For my case, it is empty by default, and the simctl command used by ios-sim causes the error.

jdeff commented 4 years ago

I updated to Xcode 11.4 and started running into this issue.

jdeff commented 4 years ago

It looks like the JSON output of xcrun simctl list runtimes --json was changed to include an isAvailable property:

❯ xcrun simctl list runtimes --json
{
  "runtimes" : [
    {
      "bundlePath" : "\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS 12.4.simruntime",
      "buildversion" : "16G73",
      "runtimeRoot" : "\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS 12.4.simruntime\/Contents\/Resources\/RuntimeRoot",
      "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-12-4",
      "version" : "12.4",
      "isAvailable" : true,
      "name" : "iOS 12.4"
    },
    {
      "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime",
      "buildversion" : "17E255",
      "runtimeRoot" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime\/Contents\/Resources\/RuntimeRoot",
      "identifier" : "com.apple.CoreSimulator.SimRuntime.iOS-13-4",
      "version" : "13.4",
      "isAvailable" : true,
      "name" : "iOS 13.4"
    },
    {
      "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/AppleTVOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/tvOS.simruntime",
      "buildversion" : "17L255",
      "runtimeRoot" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/AppleTVOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/tvOS.simruntime\/Contents\/Resources\/RuntimeRoot",
      "identifier" : "com.apple.CoreSimulator.SimRuntime.tvOS-13-4",
      "version" : "13.4",
      "isAvailable" : true,
      "name" : "tvOS 13.4"
    },
    {
      "bundlePath" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/watchOS.simruntime",
      "buildversion" : "17T256",
      "runtimeRoot" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/WatchOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/watchOS.simruntime\/Contents\/Resources\/RuntimeRoot",
      "identifier" : "com.apple.CoreSimulator.SimRuntime.watchOS-6-2",
      "version" : "6.2",
      "isAvailable" : true,
      "name" : "watchOS 6.2"
    }
  ]
}

This breaks findRuntimesGroupByDeviceProperty which determines if a runtime is available by checking if availability equals the string (available).

jdeff commented 4 years ago

Actually, it looks like this was already fixed in the latest 9.0.0 release. I was still using 9.0.0-dev.4. Updating to the latest version fixes my issue.

eastling commented 4 years ago

in my cases,until I allow command line in Xcode-perferences-locations, I fix it

vilakshangithub commented 4 years ago

I am already using the 9.0.0 release (ios-sim/9.0.0 darwin-x64 node-v11.4.0) but I am still facing the same issue. I am using Mac 10.14.x and verified whether xcode is installed or not using the following command

which g++ O/P:- /usr/bin/g++

Please suggest

christophermiles commented 4 years ago

I think I am having the same issue, running ios-sim/9.0.0 darwin-x64 node-v13.8.0 with Xcode 11.5

SyntaxError: Unexpected token I in JSON at position 0
    at JSON.parse (<anonymous>)
    at Object.list (/Users/christophermilesorygen/.config/yarn/global/node_modules/simctl/simctl.js:171:33)
    at getDeviceTypes (/Users/christophermilesorygen/.config/yarn/global/node_modules/ios-sim/src/helpers.js:29:21)
    at ShowDeviceTypesCommand.run (/Users/christophermilesorygen/.config/yarn/global/node_modules/ios-sim/src/commands/showdevicetypes.js:7:25)
    at ShowDeviceTypesCommand._run (/Users/christophermilesorygen/.config/yarn/global/node_modules/@oclif/command/lib/command.js:43:31)
TypeError: Cannot read property 'devicetypes' of undefined
    at fixSimCtlList (~/.config/yarn/global/node_modules/ios-sim/src/helpers.js:12:38)
    at getDeviceTypes (~/.config/yarn/global/node_modules/ios-sim/src/helpers.js:30:10)
    at ShowDeviceTypesCommand.run (~/.config/yarn/global/node_modules/ios-sim/src/commands/showdevicetypes.js:7:25)
    at ShowDeviceTypesCommand._run (~/.config/yarn/global/node_modules/@oclif/command/lib/command.js:43:31)

Command line tools preference in Xcode is set to Xcode 11.5

miligithub commented 3 years ago

You might need to print-path and make sure Xcode is being used and NOT Command Line Tools.

$ xcode-select --print-path
/Library/Developer/CommandLineTools
$ sudo xcode-select -s /Applications

Now do print-path again and you would see

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