Skip to content

Simulators with ( in name are not started after tns run ios --device <device_name> #2131

Closed
@asterizk

Description

@asterizk

I can't run tns emulate ios --device "iPad Pro (12.9 inch)"

Doing so results in the following message:
Starting iOS Simulator Unable to find device iPad Pro (12.9 inch). The valid device names are iPhone 5, iPhone 5s, iPhone 6, iPhone 6 Plus, iPhone 6s, iPhone 6s Plus, iPhone 7, iPhone 7 Plus, iPhone SE, iPad Retina, iPad Air, iPad Air 2

Expected result:

  • Starts 12.9" iPad simulator

This error occurs despite 'xcrun simctl list' outputting the 12.9" iPad as an option.

I believe I've tracked the root cause down to the fact that "iPad Pro (9.7 inch)" and the "iPad Pro (12.9 inch)" devices contain parentheses in their names, and the regex that parses the output of 'xcrun simctl list' doesn't expect those parentheses to be there:

var lineRegex = /^ ([^\(]+) \(([^\)]+)\) \(([^\)]+)\)( \(([^\)]+)\))*/;

That regex is contained in the following file: /usr/local/lib/node_modules/nativescript/node_modules/ios-sim-portable/lib/simctl.js.

I guess that means it's a problem with the ios-sim-portable module. I've got version 1.3.0 of it. I will file an issue with that project. In the meantime I'm working around it by manually adding devices to the device list in simctl.js:

            devices.push({
                            name: 'iPad Pro (9.7 inch)',
                            id: 'F123F133-F175-4FF4-ABA5-4A043EFCA810',
                            fullId: "com.apple.CoreSimulator.SimDeviceType.iPad Pro (9.7 inch)",
                            runtimeVersion: '10.0',
                            state: 'Shutdown'
                        });


            devices.push({
                            name: 'iPad Pro (12.9 inch)',
                            id: '07552BEF-F830-4561-912B-D760B0716935',
                            fullId: "com.apple.CoreSimulator.SimDeviceType.iPad Pro (12.9 inch)",
                            runtimeVersion: '10.0',
                            state: 'Shutdown'
                        });

...right before the return devices; statement.

Obviously that's a big hack and not a solution (the solution would involve fixing that regex), but at the present it allows me to launch my Nativescript app on the 12.9" iPad under emulation, which is pretty important for me because it's the only iOS platform my company actually supports at the moment.

Feel free to close this if issues in dependencies shouldn't be filed here. I just thought I might file it because it manifested itself while I was using 'tns' and it might help someone else out.

My config:
OS X 10.11.6
Xcode 8.0 (8A218a)
tns --version: 2.3.0
ios-sim-portable: 1.3.0
npm --version: 3.10.8
tsc --version: Version 2.0.3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions