Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
hershko opened this issue Mar 14, 2020 · 8 comments
Open

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

hershko opened this issue Mar 14, 2020 · 8 comments

Comments

@hershko
Copy link

hershko commented Mar 14, 2020

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
Copy link

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
Copy link

jdeff commented Mar 24, 2020

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

@jdeff
Copy link

jdeff commented Mar 24, 2020

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
Copy link

jdeff commented Mar 24, 2020

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
Copy link

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

@vilakshangithub
Copy link

vilakshangithub commented Jun 11, 2020

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
Copy link

christophermiles commented Jul 7, 2020

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants