Flutter : How to specify a device id in flutter? - dart

How to select a device id in flutter run?
please specify a device with the '-d ' flag, or use '-d all'
to act on all devices
iPhone 6 • 54XXXXXX35130ebefd38f • ios • iOS 10.3.3
iPhone 7 Plus • BA8CXXXXXXD0-577D675d • ios • iOS 11.2 (simulator)

Simply use
flutter run -d iPhone 6
For me this also works fine
flutter run -d BA8CXXXXXXD0-577D675d

flutter run -d "Iphone 6"
Test on MacOS High Sierra (

use the command on the terminal of android studio -
#flutter run -d "device name or id"
if the device name contains blank space it throws an error, so using device ID is better...
for example in my case the device ID was-
#flutter run -d 590******140
and it worked :)

If you need to open on simulator, try this:
Get all devices available xcrun simctl list
Output can be like this
== Devices ==
-- iOS 13.5 --
iPhone 8 (21DB8D2B-F71B-4D91-AB56-FD64A20CEEE7) (Shutdown)
iPhone 8 Plus (D4AA1ABE-D40B-437D-9373-9AF89F2A4951) (Shutdown)
iPhone 11 (44CE162D-D077-4165-BE44-33DE723FDBAB) (Shutdown)
Set the desired device xcrun simctl boot 21DB**** ( For iPhone 8)
Run flutter flutter run
If no open any simulator, run open -a Simulator

Related

Flutter IOS xcodebuild: WARNING: Using the first of multiple matching destinations:

When I run the project directly in xcode 13 everything works fine, but when compiling with flutter run I get this error, I already tried deleting the DerivedData files.
Lock the password keychain.
Deleting the Pods and all their files.
Deleting the WorkSpace.
But nothing turns out to be useful, I am from a mac m1 with Monterrey operating system, I would like to know if someone has a possible solution for this error that I have seen so recurrent
Try following by running on specific device:
step1:- Run flutter devices, You will get list of devices connected. like this.
2 connected devices:
Redmi 4 • 81cea4a7d740 • android-arm64 • Android 7.1.2 (API
25)
Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28)
(emulator),
step2:- f you want to run in a specific device Run flutter run -d Device name or Device id
eg:- flutter run -d Redmi or flutter run -d 81cea4a7d740,
step3:- If you want to run in all devices than flutter run -d all.

Xcode device Unavailable, runtime profile not found

In the following environment:
Xcode 8.3.2
react-native-cli 2.0.1
react-native: 0.44.0
macOS Sierra 10.12.5
Just updated Xcode and macOS to run React Native and keep on practicing as I was some days ago... but everytime I try to run:
react-native run-ios
I get the error:
Scanning 555 folders for symlinks in /Users/juangarcia/projects/react-tests/CountDown/node_modules (6ms)
Found Xcode project CountDown.xcodeproj
Could not find iPhone 6 simulator
I try to see the list of devices available and I get:
~/projects/react-tests/CountDownSample » xcrun simctl list devices
== Devices ==
-- iOS 10.3 --
-- tvOS 10.2 --
Apple TV 1080p (323FA90C-0366-4B5B-AEEE-D0477C61762A) (Shutdown)
-- watchOS 3.2 --
Apple Watch - 38mm (F42C0C0D-325B-41DD-948D-E44B0A08B951) (Shutdown)
Apple Watch - 42mm (75D8BAF1-27CB-47EE-9EE3-D400B962F8BC) (Shutdown)
Apple Watch Series 2 - 38mm (64D01BD4-5C37-4885-A73A-52479D9CCF4F) (Shutdown)
Apple Watch Series 2 - 42mm (8471C9FD-BCF3-4DDC-B386-F17E128C5EB1) (Shutdown)
-- Unavailable: com.apple.CoreSimulator.SimRuntime.iOS-9-3 --
iPhone 4s (1FF2D0D3-F136-43A7-8148-7B1849A7B1E3) (Shutdown) (unavailable, runtime profile not found)
iPhone 5 (859D4D90-F1B5-4DE8-B976-6984F85CAFE3) (Shutdown) (unavailable, runtime profile not found)
iPhone 5s (5B2AD8CD-9B3F-413C-BF16-FA96F807BB2B) (Shutdown) (unavailable, runtime profile not found)
iPhone 6 (2573D214-4371-47A8-BFF6-3341862954E0) (Shutdown) (unavailable, runtime profile not found)
iPhone 6 Plus (8916CD9B-4D8B-463F-8583-75A2CE4F61FD) (Shutdown) (unavailable, runtime profile not found)
iPhone 6s (41093980-7912-4F98-9D06-981A533FAAFE) (Shutdown) (unavailable, runtime profile not found)
iPhone 6s Plus (6A85D2AE-D867-4341-979C-FEE8308DE93E) (Shutdown) (unavailable, runtime profile not found)
iPad 2 (BFBB5477-B6D9-48C3-B529-516D2D9105A7) (Shutdown) (unavailable, runtime profile not found)
iPad Retina (C49B5920-F4FF-4D7F-AA74-7AE2367FF09D) (Shutdown) (unavailable, runtime profile not found)
iPad Air (4101FC8E-D8B9-4496-AD2B-1484661C15DE) (Shutdown) (unavailable, runtime profile not found)
iPad Air 2 (9952B05C-829F-428F-AC76-EB1F8FB55D72) (Shutdown) (unavailable, runtime profile not found)
iPad Pro (735082E2-4470-4D9A-BAA1-BEDA8426B725) (Shutdown) (unavailable, runtime profile not found)
-- Unavailable: com.apple.CoreSimulator.SimRuntime.tvOS-9-2 --
Apple TV 1080p (AD48DE24-6295-4EFC-9787-A9B5D8118503) (Shutdown) (unavailable, runtime profile not found)
-- Unavailable: com.apple.CoreSimulator.SimRuntime.watchOS-2-2 --
Apple Watch - 38mm (C3F2A7C3-3967-4159-9B79-13CBA63E399E) (Shutdown) (unavailable, runtime profile not found)
Apple Watch - 42mm (656005A9-7555-4872-A7FB-FB6BCB65139C) (Shutdown) (unavailable, runtime profile not found)
react takes by default Iphone 6 to work with, and it is not available
how can I make it available again? and why did this happen?
I had this issue in xCode 9 and 10.2.
For others that ends up here with the same problem, here is what helped me:
Close xCode
Restart your laptop (I know it is huge bummer)
Open xCode and run the build again
TL;DR:
Upgrade unavailable simulators to the latest (or the desired) iOS runtime using xcrun simctl upgrade
Details:
I was in this situation probably after performing a xcrun simctl delete unavailable with both Xcode 10 and Xcode 11 installed (and Xcode 10 as currently active).
Executing xcrun simctl list runtimes I found the iOS 13.1 runtime listed:
iOS 11.4 (11.4 - 15F79) - com.apple.CoreSimulator.SimRuntime.iOS-11-4
iOS 13.1 (13.1 - 17A844) - com.apple.CoreSimulator.SimRuntime.iOS-13-1
tvOS 13.0 (13.0 - 17J585) - com.apple.CoreSimulator.SimRuntime.tvOS-13-0
watchOS 6.0 (6.0 - 17R575) - com.apple.CoreSimulator.SimRuntime.watchOS-6-0
But when I executed xcrun simctl list, several simulators are listed as unavailable:
iPhone 8 Plus (B08025C1-B7A2-40C0-B6D5-517EC8BB3C45) (Shutdown) (unavailable, runtime profile not found)
iPhone Xs (0A1C1EAA-8E18-4508-9E14-C376D944984B) (Shutdown) (unavailable, runtime profile not found)
iPhone Xs Max (84C692F5-6CF3-449D-B166-0EA26B1FAC4B) (Shutdown) (unavailable, runtime profile not found)
iPhone Xʀ (7581E116-5CFB-4A94-94A0-30B5B8871874) (Shutdown) (unavailable, runtime profile not found)
My solution was to upgrade the unavailable simulators to the desired iOS runtime (iOS 13.1 in my case):
xcrun simctl upgrade SIMULATOR_ID "com.apple.CoreSimulator.SimRuntime.iOS-13-1"
To avoid having to perform this manually for all simulators I wrote this small ruby script to upgrade all the iPhones at once:
#!/usr/bin/ruby
uuid_regex = /([0-9A-Z]{8}-[0-9A-Z]{4}-[0-9A-Z]{4}-[0-9A-Z]{4}-[0-9A-Z]{12})/
unavailable_iPhones = `xcrun simctl list | grep iPhone | grep "runtime profile not found"`.split("\n")
unavailable_iPhones.each do | row |
uuid = row.match(uuid_regex).captures.first
system("xcrun simctl upgrade #{uuid} \"com.apple.CoreSimulator.SimRuntime.iOS-13-1\"")
end
pfff it was simpler than expected... when installing SO and Xcode, by some reason, the whole list of devices where removed... going to Xcode UI menu adding a new simulator in this case iPhone 6 was enough... I tried restarting and going back, and so on did not know there was an option in UI for this as I am new to XCode environment. thx for the answers.
In the XCode menu, Window --> Devices --> Add the new simulator...
I went to
node_modules/react-native/local-cli/runIOS/findMatchingSimulator.js
And i've replaced:
if (version.indexOf('iOS') !== 0 )
with
if (!version.includes("iOS" ))
And
if (simulator.availability !== '(available)')
with
if (simulator.isAvailable !== true)
Missing ios14 simulator option in Xcode 12 beta 4 workaround:
Check out this fantastic article about simctl.
I created an iOS14 sim since the XC12-beta4 was not giving me a download / create option via:
xcrun simctl create <name> <device> <os>
ex.
xcrun simctl create iPhone-8Plus-14 com.apple.CoreSimulator.SimDeviceType.iPhone-8-Plus com.apple.CoreSimulator.SimRuntime.iOS-14-0
If you have or have had multiple versions of Xcode open, you may need to reboot or completely re-install the CoreSimulatorService, an evil, globally installed background service that somehow remains online and available to many versions of Xcode despite it being compatible with only one version.
See more here: https://stackoverflow.com/a/72946533/731285
Other symptoms of this issue: Simulators not showing up in the Window > Devices and Simulators listing and the following:
Command CompileAssetCatalog failed with a nonzero exit code
Encountered an error communicating with IBAgent-iOS. Failed to boot device iPhone Xs

How can I launch the iOS Simulator from Terminal?

I can build using the Xcode command line tools, is there any way I can actually run the application using them? (E.g. the equivalent to pressing Cmd+R in Xcode)
Type this in terminal:
open -a Simulator.app
First decide what device you want to use:
xcrun simctl list
This will give you a list of devices:
-- iOS 9.0 --
iPhone 4s (56632E02-650E-4C24-AAF4-5557FB1B8EB2) (Shutdown)
iPhone 5 (ACD4DB7B-9FC9-49D5-B06B-BA5D5E2F5165) (Shutdown)
iPhone 5s (A8358B76-AD67-4571-9EB7-FFF4D0AC029E) (Shutdown)
iPhone 6 (1D46E980-C127-4814-A1E2-5BE47F6A15ED) (Shutdown)
iPhone 6 Plus (FD9F726E-453A-4A4C-9460-A6C332AB140B) (Shutdown)
Choose the ID (eg. FD9F726E-453A-4A4C-9460-A6C332AB140B) you want (you can create your own device using xcrun simctl create if you want).
Boot the simulator with that device (replacing YOUR-DEVICE-ID with the ID)
/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator -CurrentDeviceUDID <YOUR-DEVICE-ID>
Now you should be able to use simctl to install and launch commands.
xcrun simctl install <YOUR-DEVICE-ID> <PATH-TO-APPLICATION-BUNDLE>
xcrun simctl launch <YOUR-DEVICE-ID> <BUNDLE-ID-OF-APP-BUNDLE>
xcrun simctl help for more details. Note that booting a device using simctl does not currently (Xcode 7.2) allow you to do anything else with that device such as launch or install applications. You need to launch the device in the simulator to actually do anything interesting. Also, you cannot delete a device that is in use by the simulator, so you will have to quit/kill the simulator before attempting to delete anything.
open -a simulator
it worked for me
This is the answer you are looking for:
Open terminal
xcrun simctl list
Get udid of the device you want to launch
Paste this in the terminal
open -a Simulator --args -CurrentDeviceUDID 0566AC33-9B91-2DR2-B5BB-C916D3BA8MD3
Open your terminal and paste this code:
open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app
Use xcrun simctl list to get a list of simulators and their UDIDs.
Then open a specific simulator using xcrun simctl boot <UDIDs>
open /Applications/Xcode.app/Contents/Developer/Applications/iOS\ Simulator.app/
One of the best solution :
Launch iOS simulator from Terminal by providing name of the device
xcrun simctl boot $(xcrun simctl list devices | grep -m 1 'iPhone 12
Pro' |grep -E -o -i '([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})')
This cmd will seamlessly launch the ios simulator for 'iPhone 12 Pro' device
# Update
In the new Xcode update, supported simulators are from iPhone 8 onwards
summing-up
open -a Simulator && xcrun simctl boot 'iPhone 8 Plus'

Xcode 6 - Launch simulator from command line

I want to launch iPhone simulator from command line.
until now I have been using the below command
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app/Contents/MacOS/iPhone Simulator -SimulateDevice
-SimulateDevice is used to launch a specific device type
Now with Xcode 6 the path and the app has been changed to
/Applications/Xcode.app/Contents/Developer/Applications/iOS Simulator.app/Contents/MacOS/iOS Simulator
but sadly -SimulateDevice option is not working now. I can launch the simulator, but dont have an option to specify which one to launch
Anyone found any alternatives for this with Xcode 6?
Found a way to achieve what I wanted.
Apple has introduced an interesting tool with Xcode 6!
simctl
simclt allows you to control the simulator that are running.
run xcrun simctl to get the list of available subcommands. Lots of new options to play around with.
Now to do what I wanted, here is the command to launch the simulator:
xcrun instruments -w "iPhone 5 (8.0 Simulator)"
-w is to provide a device type and to get the list of available devices.
Just execute this:
xcrun instruments -s
After launching the simulator you can control it using simctl
To install your app:
xcrun simctl install booted <app path>
To launch the app:
xcrun simctl launch booted <app identifier>
With Xcode 6, if you want to have the iOS Simulator.app boot a specific device when it launches, you can run this from the command line:
open -a "iOS Simulator" --args -CurrentDeviceUDID <DEVICE UDID>
where you can figure out the UDID of the device you want to boot from:
xcrun simctl list
With Xcode 7, the application was renamed Simulator.app, so you should update the above accordingly to:
open -a Simulator --args -CurrentDeviceUDID <DEVICE UDID>
For xcode 7:
open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app --args -CurrentDeviceUDID <DeviceUDID>
Get your simulator udid's from xcrun simctl list
To launch a simulator with a specific device booted I´m using list devices subcommand to get the list of all devices available
$ xcrun simctl list devices
== Devices ==
-- iOS 11.2 --
iPhone 5s (E3B6EA43-C805-49C2-9502-A44A465D8DF2) (Shutdown)
iPhone 6 (801E9E11-CA86-473A-9879-4B0742B827FB) (Shutdown)
iPhone 6 Plus (24013349-1A6F-489C-9A68-ABB00EBB4BBF) (Shutdown)
iPhone 6s (1A594D75-146C-4BEA-A250-1FADE7886114) (Shutdown)
iPhone 6s Plus (C2730FA0-11CB-49C9-A087-CB3C1BF1CC3D) (Shutdown)
iPhone 7 (F58B3749-3276-49E5-81C8-EBA1AEA7B242) (Shutdown)
iPhone 7 Plus (98167D8C-8F27-404C-AB02-588D9AAFD071) (Shutdown)
iPhone 8 (96322368-F763-4E0A-8576-ADE9F678211F) (Shutdown)
iPhone 8 Plus (E916D1EE-B67B-4C01-B3F5-C5C80CC4CDF8) (Shutdown)
iPhone SE (ABEFEDDF-7A7C-4B94-9E91-E065170FA47F) (Shutdown)
iPhone X (84DAB7AB-3CA2-4F5B-8C4E-A5B54CA15C31) (Shutdown)
iPad Air (DCD8CF4B-2C9F-4BA1-952A-ACB9CAD0A84D) (Shutdown)
iPad Air 2 (A47C9A05-233F-450F-9A39-318258E9ADEA) (Shutdown)
iPad (5th generation) (819C058E-64AC-4E73-8F41-2C0F919F8B56) (Booted)
this command will output a list of available devices with its UDIDs and statuses
Then I launch the simulator app specifying a device with the -CurrentDeviceUDID option
/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator -CurrentDeviceUDID <DEVICE-UDID>
NOTE: replace the with a valid UDID from the list.
For example, if we want to launch the simulator with an Ipad (% generation booted):
/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator -CurrentDeviceUDID 84DAB7AB-3CA2-4F5B-8C4E-A5B54CA15C31
UPDATE 23/05/2018
With Xcode 9.3 CurrentDevice UDID option is not working for me, as a workaround, I have to use simctl to boot the device in the simulator before open it.
xcrun simctl boot 2BF01FC0-7E29-4AF1-ADD1-886DF129A9A9
open -a Simulator
You can create, erase, delete, boot, shutdown and upgrade simulators using simctl.
$ xcrun simctl create
Usage: simctl create <name> <device type id> <runtime id>
$ xcrun simctl delete
Usage: simctl delete <device> [... <device n>] | unavailable
To get the list of valid device types and runtimes
xcrun simctl list devicetypes
xcrun simctl list runtimes
To boot a simulator:
xcrun simctl boot "iPhone X"
It will boot as a headless mode.
To make the simulator visible:
open -a Simulator
xcrun simctl boot is simpler than xcrun instruments -w. instruments requires the full device name.
You can specify the hardware and iOS version with -w flag. The format is
instruments -w "simulator-version"
For eg:
instruments -w "iPhone Retina (3.5-inch) - Simulator - iOS 7.1".
You will get the available hardvare-iOS combinations by using the instruments -w help command.
Verified in Xcode 9.4.1
Device list in a REALLY NICE FORMAT:
~/Library/Developer/CoreSimulator/Devices/device_set.plist
Root
DefaultDevices
com.apple.CoreSimulator.SimRuntime.iOS-8-4
com.apple.CoreSimulator.SimDeviceType.iPad-Retina : AB335FAF-E3E3-4AE9-A0AF-D1C6AEB5FBD4
Then you want to run (open) your Simulator app and make sure that a new instance of the app is launched.
The app is here:
/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app
And the format you'd use is like this:
open -n -a <SimulatorPath> --args -CurrentDeviceUDID <SimDeviceTypeUDID>
So, if I wanted to launch the Simulator above, I'd do this.
open -n -a /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app --args -CurrentDeviceUDID AB335FAF-E3E3-4AE9-A0AF-D1C6AEB5FBD4
Hot damn! I just tested it and it works on Mac OS 10.11.6. Now the next trick is telling the Simulator to open our installed app. I'm not there yet. Hope this helps. Thanks to https://stackoverflow.com/users/726106/jeremy-huddleston-sequoia for his detailed explanation.
Run this command. The app will be restarted followed by changes. No need to rebuild it again.
ios-sim "launch" "/Library/WebServer/Documents/testapp/build/iphone/build/Debug-iphonesimulator/test.app" "--devicetypeid" "iPad-2" "--exit";
For devicetypeid list:
ios-sim showdevicetypes
Anyone having this issue, this command will open the ios simulator from command prompt
open -a simulator

Cordova: start specific iOS emulator image

I'm developing a cross-platform mobile app using Cordova, focussing mainly on iOS in the development stage.
For my development process it would be ideal if I could start my Cordova app directly from the command line and have it load into a specified emulator. I can do this by running the following from the project root directory:
$cordova run --debug --emulator iOS
This works fine, and results in an iOS-simulator running my app in a simulated iPhone 4 Retina with iOS 7.0.3
Besides this simulated device, I would also like to test on (for instance) an iPad. I have these emulation images installed, and I can start my app in them manually in Xcode. Also, the command list-emulator-images (located in project_dir/platforms/ios/cordova/lib) gives the following output:
"iPhone Retina (3.5-inch)"
"iPhone Retina (4-inch)"
"iPhone Retina (4-inch 64-bit)"
"iPhone"
"iPad"
"iPad Retina"
However, the thing is: I can't seem to figure out how to start the emulator in anything other than the default (which appears to be the iPhone Retina (4-inch) emulation image). The relevant output of cordova help gives the following information:
run [--debug|--release]
[--device|--emulator|--target=FOO]
[PLATFORM] ............................ deploys app on specified platform devices / emulators
I've tried things like the following:
cordova run --debug --emulator=iPad iOS
And many variations thereof, but no luck. Every time it starts in the same emulator.
The documentation for the command-line tool doesn't offer any information in this regard, and an extensive Google-search also failed to turn up anything. Am I missing something trivial? Or am I trying to do something weird? I really hope someone here has experience with this, and can provide some answers.
Thanks very much in advance!
edit: forgot to mention explicitly; I'm doing all this on a Mac. As mentioned earlier, running the app in different emulators/simulators in Xcode works fine.
To find out what are the simulator images available you can use to list them
$ cordova emulate ios --list
Available iOS Virtual Devices:
iPhone-4s, 9.3
iPhone-5, 9.3
iPhone-5s, 9.3
iPhone-6, 9.3
iPhone-6-Plus, 9.3
iPhone-6s, 9.3
iPhone-6s-Plus, 9.3
iPad-2, 9.3
iPad-Retina, 9.3
iPad-Air, 9.3
iPad-Air-2, 9.3
iPad-Pro, 9.3
Then use one of the simulator names in the --target parameter:
cordova emulate ios --target="iPhone-4s, 9.3"
cordova emulate ios --target="iPad-Air-2, 9.3"
cordova emulate ios --target="iPhone-6s, 9.3"
cordova emulate ios --target="iPhone-6-Plus, 9.3"
Important Quit the simulator before launching a different target simulator (On Menu bar select Simulator->Quit)
Take into account that you may need to quit the iOS simulator via menu to switch from 3.5 to 4 inch iPhone.
dynamic list is available in platforms/ios/cordova/lib/list-emulator-images
As say csantanapr you can use:
cordova emulate ios --target="iPhone-4s"
but, in this case cordova (or PhoneGap or other) project will be launched on iPhone 4s simulator with iOS version 7.0.3.
If you want launch project on same simulator, but with other version iOS (7.1 or 8.0, if it versions exist in your system)?
Of corse, you can do like say cobberboy:
start a specific emulator and choose your ios version by directly using ios-sim.
But you can improve --target option of cordova run command.
At first you must ensure what target iOS version available on your system.
For it use answer of cobberboy:
$ ios-sim showdevicetypes
Then you need to open the file your_project_dir/platforms/ios/cordova/lib/run.js and find lines of code like below:
// validate target device for ios-sim
// Valid values for "--target" (case sensitive):
var validTargets = ['iPhone-4s', 'iPhone-5', 'iPhone-5s', 'iPhone-6-Plus', 'iPhone-6',
'iPad-2', 'iPad-Retina', 'iPad-Air', 'Resizable-iPhone', 'Resizable-iPad'];
For use iPhone-4s, 7.1 (or some other) simple add it to array validTargets.
var validTargets = ['iPhone-4s', 'iPhone-4s, 7.1', 'iPhone-5', 'iPhone-5s', 'iPhone-6-Plus', 'iPhone-6',
'iPad-2', 'iPad-Retina', 'iPad-Air', 'Resizable-iPhone', 'Resizable-iPad'];
And in
cordova emulate ios --target="iPhone-4s, 7.1"
your --target="iPhone-4s, 7.1" will be valid.
And function deployToSim of run.js:
function deployToSim(appPath, target) {
// Select target device for emulator. Default is 'iPhone-6'
if (!target) {
target = 'iPhone-6';
console.log('No target specified for emulator. Deploying to ' + target + ' simulator');
}
var logPath = path.join(cordovaPath, 'console.log');
var simArgs = ['launch', appPath,
'--devicetypeid', 'com.apple.CoreSimulator.SimDeviceType.' + target,
// We need to redirect simulator output here to use cordova/log command
// TODO: Is there any other way to get emulator's output to use in log command?
'--stderr', logPath, '--stdout', logPath,
'--exit'];
return spawn('ios-sim', simArgs);
}
convert iPhone-4s, 7.1 to valid argument com.apple.CoreSimulator.SimDeviceType.iPhone-4s, 7.1 for ios-sim.
TL;DR
You can start a specific emulator and choose your ios version by directly using ios-sim.
export appname="./platforms/ios/build/emulator/Hello World.app"
ios-sim launch "$appname" --devicetypeid "com.apple.CoreSimulator.SimDeviceType.iPad-2, 8.0" --stderr ./platforms/ios/cordova/console.log --stdout ./platforms/ios/cordova/console.log
Details
When I ran this:
cordova emulate ios --target="iPad"
and looked at the processes running, I saw this (on a single line):
ios-sim launch ./platforms/ios/build/emulator/HelloWorld.app
--stderr ./platforms/ios/cordova/console.log
--stdout ./platforms/ios/cordova/console.log
--family ipad
--exit
Investigating further into ios-sim, it looks like there are some more specific options, particularly:
--devicetypeid <device type> The id of the device type that should be simulated (Xcode6+). Use 'showdevicetypes' to list devices.
e.g "com.apple.CoreSimulator.SimDeviceType.Resizable-iPhone6, 8.0"
So I did as it suggested and ran ios-sim with a "showdevicetypes" argument and got this:
$ ios-sim showdevicetypes
com.apple.CoreSimulator.SimDeviceType.iPhone-4s, 7.1
com.apple.CoreSimulator.SimDeviceType.iPhone-5, 7.1
com.apple.CoreSimulator.SimDeviceType.iPhone-5s, 7.1
com.apple.CoreSimulator.SimDeviceType.iPad-2, 7.1
com.apple.CoreSimulator.SimDeviceType.iPad-Retina, 7.1
com.apple.CoreSimulator.SimDeviceType.iPad-Air, 7.1
com.apple.CoreSimulator.SimDeviceType.iPhone-4s, 8.0
com.apple.CoreSimulator.SimDeviceType.iPhone-5, 8.0
com.apple.CoreSimulator.SimDeviceType.iPhone-5s, 8.0
com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus, 8.0
com.apple.CoreSimulator.SimDeviceType.iPhone-6, 8.0
com.apple.CoreSimulator.SimDeviceType.iPad-2, 8.0
com.apple.CoreSimulator.SimDeviceType.iPad-Retina, 8.0
com.apple.CoreSimulator.SimDeviceType.iPad-Air, 8.0
com.apple.CoreSimulator.SimDeviceType.Resizable-iPhone, 8.0
com.apple.CoreSimulator.SimDeviceType.Resizable-iPad, 8.0
Don't include version number
cordova run ios --target="iPhone-6s"
As of Xcode 8.3.2...
Old thread, I know, but it seems, perhaps, that the answer has changed slightly. The hints from earlier posts in this thread helped, but so did reading the documentation included in the code, <cordova-project>/platforms/ios/cordova/lib/run.js
Execute ./platforms/ios/cordova/lib/list-emulator-images to list the available emulator images. Do not include the version number on the end when making the cordova call to run in the desired emulator.
cordova run ios --emulator --target="iPad-Air"
See more
I can't comment on the answer above due to my low reputation, but the list of targets is available from:
start-emulator
under
your platform/ios/cordova/lib/
Having said that, I cannot make the ipad retina emulator work...
fastest output of devices list:
$ instruments -s devices
Just use the device name without the version.
Now is:
cordova run ios --list
Available ios devices:
Available ios virtual devices:
Apple-TV-1080p, tvOS 14.3
Apple-TV-4K-4K, tvOS 14.3
Apple-TV-4K-1080p, tvOS 14.3
Apple-Watch-Series-5-40mm, watchOS 7.2
Apple-Watch-Series-5-44mm, watchOS 7.2
Apple-Watch-Series-6-40mm, watchOS 7.2
Apple-Watch-Series-6-44mm, watchOS 7.2
iPhone-8, 14.3
iPhone-8-Plus, 14.3
iPhone-11, 14.3
iPhone-11-Pro, 14.3
iPhone-11-Pro-Max, 14.3
iPhone-SE--2nd-generation-, 14.3
iPhone-12-mini, 14.3
iPhone-12, 14.3
iPhone-12-Pro, 14.3
iPhone-12-Pro-Max, 14.3
iPod-touch--7th-generation-, 14.3
iPad-Pro--9-7-inch-, 14.3
iPad-Pro--11-inch---2nd-generation-, 14.3
iPad-Pro--12-9-inch---4th-generation-, 14.3
iPad--8th-generation-, 14.3
iPad-Air--4th-generation-, 14.3
And:
cordova run ios --target="iPad-Pro--12-9-inch---4th-generation-, 14.3"
In Cordova 10.0.0
Different iphone and ipad simulator
cordova run ios --list
cordova emulate ios --target "iPhone-7"
Runs iOS simulator with web request based on already generated build for cordova application.
Execute this request from browser opens simulator on mac with iPhone 8Plus version:
http://hostname:3000/cordova/build/[xxxx-buildnumber]/emulate?target=iPhone-8-Plus
#Birja's answer is working right now but the run command he used finally is still wrong so here the right answer:
To list all the devices available in simulator cordova run ios --list
It will result in something like this:
Available ios devices:
Available ios virtual devices:
Apple-TV-1080p, tvOS 12.2
Apple-Watch-Series-2-38mm, watchOS 5.2
iPhone-5s, 12.2
iPhone-6, 12.2
iPad-Air-2, 12.2
iPad--5th-generation-, 12.2
iPad-Pro--9-7-inch-, 12.2
iPad-Pro, 12.2
iPad-Pro--12-9-inch---2nd-generation-, 12.2
iPad-Pro--10-5-inch-, 12.2
iPad--6th-generation-, 12.2
iPad-Pro--11-inch-, 12.2
iPad-Pro--12-9-inch---3rd-generation-, 12.2
cordova run ios --target "iPad-Pro, 12.2" Use any target from the above. To run in simulator.

Resources