nativescript-cli: Simulators with `(` in name are not started after `tns run ios --device `

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

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 5
  • Comments: 20 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Fixed in 4.0.1 RC (4.0.1-2018-04-23-11424). Now you can do things like this:

tns run ios --device 'iPad Pro (12.9-inch) (2nd generation)' --sdk 11.3

To see all available devices and sdks run this:

tns device ios --available-devices

Thanks for keeping the issue up-to-date guys, and for your time. @dtopuzov @pkoleva @rosen-vladimirov. Am I correct in my assertion that this is basically a “ios-sim-portable” issue, manifesting itself within the Nativescript CLI?

Hey guys, First of all, thank you for your patience and collaboration. We’ve just released version 1.6.2 of ios-sim-portable, which will allow you to use iPad Pro (9.7 inch) and iPad Pro (12.9 inch) devices. However there are some other issues in CLI, so you’ll have to start the simulator first and use:

$ tns emulate ios

after that. In order to use the new version, you’ll have to reinstall your CLI:

$ npm uninstall -g nativescript
$ npm install -g nativescript

I’ll keep this issue open until we fix the whole behavior, so --device flag will also work with iPad Pro.

Can you try reinstalling NativeScript CLI and see if you are able to deploy on the iPad Pro emulators?

@nraboy , @grasshoppermouse , @tjvantoll sorry for this issue 😿 I’ll raise it’s priority and will try to take a look at the issue by the end of the week. Meanwhile can you provide the following information, while the iPad simulator is running:

$ tns device --log trace
$ xcrun simctl list devices

As a workaround you may try the following:

$ tns build ios --emulator

This will build your application for iOS Simulator. Find the output in your platforms/iOS/<project name>/build/emulator/<project name>.app (the path may vary on your environment).

After that, make sure your iOS Simulator (the problematic iPad one) is running and execute:

$ xcrun simctl list devices | grep -i booted

From this line get the identifier of the booted device. After that try the following:

$ xcrun simctl install <device id> <path to .app>
$ xcrun simctl launch <device id> <app identifier>

@nraboy , @grasshoppermouse you can change the device type of your simulator by executing the following steps:

  1. Start the simulator
  2. From the top menu select Hardware -> Device -> iOS 10.1 -> iPad Pro (12.9 inch)
  3. After the simulator is currently running, execute your CLI command: tns run ios - CLI will respect the already running emulator.

Hoep this helps.