NativeScript / mobile-devices-controller

MIT License
3 stars 6 forks source link

Mobile devices controller reports all of my simulators as type "watch" #11

Open jnorkus opened 5 years ago

jnorkus commented 5 years ago

I've traced it down to this part of code in the ios-controller:

const stringType = /\w+[a-z]/g.test(level) && /\w+[a-z]/g.exec(level)[0];
let type = DeviceType.SIMULATOR;
if (stringType) {
  type = stringType === "tv" ? DeviceType.TV : DeviceType.WATCH;
}
Smirking commented 5 years ago

Have noted same issue, appears to do with how XCode10 describes ApiLevels . previously in XCode9 (iOS 11 etc) they are written as

watchOS 4.3
tvOS 11.4
iOS 11.4

in newer XCode10 (iOS 12 etc) they are written as

com.apple.CoreSimulator.SimRuntime.tvOS-12-2
com.apple.CoreSimulator.SimRuntime.watchOS-5-2
com.apple.CoreSimulator.SimRuntime.iOS-12-2

and the string matching is just picking out com and therefore not matching anything, defaulting to DeviceType.WATCH

Working on a PR, something like

const stringType = /(watchos|tvos|ios)/g.exec(level.toLowerCase())[0]
let type = enums_1.DeviceType.SIMULATOR;
if (stringType) {
    if (stringType === "tvos") {
        type = enums_1.DeviceType.TV;
    } else if (stringType === "watchos") {
        type = enums_1.DeviceType.WATCH;
    }
}