No virtual devices found - Ionic Cordova Emulate iOS - ios

I am trying to emulate my Ionic app in iOS but when I run ionic cordova emulate ios I get an error:
No target specified for emulator. Deploying to undefined simulator
Device type "com.apple.CoreSimulator.SimDeviceType.undefined" could not be found.
It seems that even though there are emulators available on my OSX, Ionic can't access them for some reason. Why are there no devices found in Ionic when there are clearly devices that can be run elsewhere? Could this be an issue with env vars?
For reference: ionic info:
cli packages: (/usr/local/lib/node_modules)
#ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 7.0.1
local packages:
#ionic/app-scripts : 3.1.10
Cordova Platforms : android 6.2.3 ios 4.4.0
Ionic Framework : ionic-angular 3.9.2
System:
ios-sim : 7.0.0
Node : v9.1.0
npm : 6.0.0
OS : macOS High Sierra
Xcode : Xcode 9.4.1 Build version 9F2000
Environment Variables:
ANDROID_HOME : not set
Misc:
backend : pro
When I run ionic cordova emulate ios --list I get the following output:
Available ios virtual devices:
However, when I run ios-sim showdevicetypes I get:
Apple-Watch-38mm, watchOS 4.3
Apple-Watch-42mm, watchOS 4.3
Apple-Watch-Series-2-38mm, watchOS 4.3
Apple-Watch-Series-2-42mm, watchOS 4.3
Apple-Watch-Series-3-38mm, watchOS 4.3
Apple-Watch-Series-3-42mm, watchOS 4.3
iPhone-5s, 11.4
iPhone-6, 11.4
iPhone-6-Plus, 11.4
iPhone-6s, 11.4
iPhone-6s-Plus, 11.4
iPhone-7, 11.4
iPhone-7-Plus, 11.4
iPhone-8, 11.4
iPhone-8-Plus, 11.4
iPhone-SE, 11.4
iPhone-X, 11.4
iPad-Air, 11.4
iPad-Air-2, 11.4
iPad--5th-generation-, 11.4
iPad-Pro--9-7-inch-, 11.4
iPad-Pro, 11.4
iPad-Pro--12-9-inch---2nd-generation-, 11.4
iPad-Pro--10-5-inch-, 11.4
Apple-TV-1080p, tvOS 11.4
Apple-TV-4K-4K, tvOS 11.4
Apple-TV-4K-1080p, tvOS 11.4
And running xcrun simctl list gives:
== Device Types ==
iPhone 4s (com.apple.CoreSimulator.SimDeviceType.iPhone-4s)
iPhone 5 (com.apple.CoreSimulator.SimDeviceType.iPhone-5)
iPhone 5s (com.apple.CoreSimulator.SimDeviceType.iPhone-5s)
iPhone 6 (com.apple.CoreSimulator.SimDeviceType.iPhone-6)
iPhone 6 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus)
iPhone 6s (com.apple.CoreSimulator.SimDeviceType.iPhone-6s)
iPhone 6s Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-6s-Plus)
iPhone 7 (com.apple.CoreSimulator.SimDeviceType.iPhone-7)
iPhone 7 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-7-Plus)
iPhone 8 (com.apple.CoreSimulator.SimDeviceType.iPhone-8)
iPhone 8 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-8-Plus)
iPhone SE (com.apple.CoreSimulator.SimDeviceType.iPhone-SE)
iPhone X (com.apple.CoreSimulator.SimDeviceType.iPhone-X)
iPad 2 (com.apple.CoreSimulator.SimDeviceType.iPad-2)
iPad Retina (com.apple.CoreSimulator.SimDeviceType.iPad-Retina)
iPad Air (com.apple.CoreSimulator.SimDeviceType.iPad-Air)
iPad Air 2 (com.apple.CoreSimulator.SimDeviceType.iPad-Air-2)
iPad (5th generation) (com.apple.CoreSimulator.SimDeviceType.iPad--5th-generation-)
iPad Pro (9.7-inch) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro--9-7-inch-)
iPad Pro (12.9-inch) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro)
iPad Pro (12.9-inch) (2nd generation) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro--12-9-inch---2nd-generation-)
iPad Pro (10.5-inch) (com.apple.CoreSimulator.SimDeviceType.iPad-Pro--10-5-inch-)
iPad (6th generation) (com.apple.CoreSimulator.SimDeviceType.iPad--6th-generation-)
Apple TV (com.apple.CoreSimulator.SimDeviceType.Apple-TV-1080p)
Apple TV 4K (com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-4K)
Apple TV 4K (at 1080p) (com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-1080p)
Apple Watch - 38mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-38mm)
Apple Watch - 42mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-42mm)
Apple Watch Series 2 - 38mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-38mm)
Apple Watch Series 2 - 42mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-2-42mm)
Apple Watch Series 3 - 38mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-38mm)
Apple Watch Series 3 - 42mm (com.apple.CoreSimulator.SimDeviceType.Apple-Watch-Series-3-42mm)
== Runtimes ==
iOS 11.4 (11.4 - 15F79) - com.apple.CoreSimulator.SimRuntime.iOS-11-4
tvOS 11.4 (11.4 - 15L576) - com.apple.CoreSimulator.SimRuntime.tvOS-11-4
watchOS 4.3 (4.3 - 15T212) - com.apple.CoreSimulator.SimRuntime.watchOS-4-3
== Devices ==
-- iOS 11.4 --
iPhone 5s (68553C20-B109-4807-B20C-E93006B8F214) (Shutdown)
iPhone 6 (9B230488-BC8B-4947-AC2B-3B8245878625) (Shutdown)
iPhone 6 Plus (028C9FB4-4179-4772-AC96-9AEC9F447859) (Shutdown)
iPhone 6s (BFBFF883-1207-4049-851B-DDFF15D7A7D5) (Shutdown)
iPhone 6s Plus (6030E33B-DE97-41A6-A961-6C05DEA2EA34) (Shutdown)
iPhone 7 (0F1EE195-BB50-44D3-B87C-DB914196BB68) (Shutdown)
iPhone 7 Plus (42FDB489-30D3-4BEE-82F1-D6BCA84019F2) (Shutdown)
iPhone 8 (62895939-A322-4F3D-8D4E-8D8F3F44B98E) (Shutdown)
iPhone 8 Plus (79D7D0A1-03CE-425D-A714-13CE8E62BCB3) (Shutdown)
iPhone SE (82AC6B87-D98E-46A2-BE34-7F148F179796) (Shutdown)
iPhone X (FEA0BBCA-91C3-4EE3-A49A-7EE2BC4382A4) (Shutdown)
My-iPhoneX (A2E78F04-CB1B-4BCE-8BF3-8EA1B14930E5) (Shutdown)
iPad Air (6F05FAB3-7094-485E-B518-CE6EC1D46D54) (Shutdown)
iPad Air 2 (2A075B9A-35B3-410D-8D18-308A94F49F1D) (Shutdown)
iPad (5th generation) (879A193F-2AF3-4446-BB63-095AE6C9C3E6) (Shutdown)
iPad Pro (9.7-inch) (025D91DC-43CE-4497-A672-B57857BF6E68) (Shutdown)
iPad Pro (12.9-inch) (2D1C41EA-5F2E-493F-98C8-29FCCDB35D0F) (Shutdown)
iPad Pro (12.9-inch) (2nd generation) (96467014-EDC9-47EE-84FE-29AB7817B742) (Shutdown)
iPad Pro (10.5-inch) (47BEFF82-F240-4105-868D-CA4C8EE3BF29) (Shutdown)
-- tvOS 11.4 --
Apple TV (E3696606-A26C-4BCE-9CC3-1DC99B148ED3) (Shutdown)
Apple TV 4K (087290EA-40C9-4EEC-8A80-9D0A92378FA5) (Shutdown)
Apple TV 4K (at 1080p) (71014E88-3FEF-450A-B315-3C224271401A) (Shutdown)
-- watchOS 4.3 --
Apple Watch - 38mm (7914DF5F-9810-4995-908F-1BABBAE02670) (Shutdown)
Apple Watch - 42mm (A335D9E6-7974-45F6-B47D-3747FA9BD09E) (Shutdown)
Apple Watch Series 2 - 38mm (7FBCB06A-EE99-4C8F-BDD2-870EC5275EF0) (Shutdown)
Apple Watch Series 2 - 42mm (806DDCC1-588A-455D-AA1A-16F5E5931077) (Shutdown)
Apple Watch Series 3 - 38mm (DF16B352-301E-4221-81CA-2869A1F9B527) (Shutdown)
Apple Watch Series 3 - 42mm (85C06E5F-3E1A-4BC4-AECB-4EA0C88D8F09) (Shutdown)
== Device Pairs ==
BE73638A-71E6-41F2-A1EA-3372E898F1B0 (active, disconnected)
Watch: Apple Watch Series 2 - 38mm (7FBCB06A-EE99-4C8F-BDD2-870EC5275EF0) (Shutdown)
Phone: iPhone 7 (0F1EE195-BB50-44D3-B87C-DB914196BB68) (Shutdown)
E17C2241-7367-4F02-AC44-54542EDBC936 (active, disconnected)
Watch: Apple Watch Series 2 - 42mm (806DDCC1-588A-455D-AA1A-16F5E5931077) (Shutdown)
Phone: iPhone 7 Plus (42FDB489-30D3-4BEE-82F1-D6BCA84019F2) (Shutdown)
A463C9D5-E753-46F8-9493-D1A3E3BDCAA1 (active, disconnected)
Watch: Apple Watch Series 3 - 38mm (DF16B352-301E-4221-81CA-2869A1F9B527) (Shutdown)
Phone: iPhone 8 (62895939-A322-4F3D-8D4E-8D8F3F44B98E) (Shutdown)
7A7B90CE-9B4F-41A6-8721-C7457E9F4A4E (active, disconnected)
Watch: Apple Watch Series 3 - 42mm (85C06E5F-3E1A-4BC4-AECB-4EA0C88D8F09) (Shutdown)
Phone: iPhone 8 Plus (79D7D0A1-03CE-425D-A714-13CE8E62BCB3) (Shutdown)
There are lots of bits of code here because it requires output logs.

Or you could just try something like this :
cd platforms/ios/cordova
npm install ios-sim#latest

If this problem again persist after updating to Mojave then remove and add platform will not going to work.
Instead you can try invoking simulator directly using following command
ionic cordova emulate ios --livereload --consolelogs --target="iPhone-6,com.apple.CoreSimulator.SimRuntime.iOS-12-2"
Also, if you are using older build system, you can add additional flag like below
ionic cordova emulate ios --livereload --consolelogs --target="iPhone-6,com.apple.CoreSimulator.SimRuntime.iOS-12-2" --buildFlag="-UseModernBuildSystem=0"

As of Ionic v5.4.1 and ios-sim#latest (8.0.2), none of the other answers worked for me. What ended up working was running the list command to find the device's UUID then specifying it as the target:
ionic cordova emulate --list
ionic cordova emulate ios -l -c --target="<UUID>"

Had to remove ios platform and add it
ionic cordova platform remove ios
ionic cordova platform add ios

Related

open iOS iPad simulator with React Native

When testing a React Native app with react-native run-ios it opens an iPhone simulator.
You can change the virtual device to an iPad in the Simulator options, but the React Native app does not appear in the list of installed apps.
Is there a way to open an iPad simulator from the CLI?
--simulator flag is what you are looking for
For example react-native run-ios --simulator 'iPad 2' will run the app on iPad 2 simulator.
As a side node, if you need to get list of available simulators with their names use xcrun simctl list devices
Get device list with this command
xcrun simctl list devices
Console
== Devices ==
-- iOS 13.5 --
iPhone 6s (9981E5A5-48A8-4B48-B203-1C6E73243E83) (Shutdown)
iPhone 8 (FC540A6C-F374-4113-9E71-1291790C8C4C) (Shutting Down)
iPhone 8 Plus (CAC37462-D873-4EBB-9D71-7C6D0C915C12) (Shutdown)
iPhone 11 (347EFE28-9B41-4C1A-A4C3-D99B49300D8B) (Shutting Down)
iPhone 11 Pro (5AE964DC-201C-48C9-BFB5-4506E3A0018F) (Shutdown)
iPhone 11 Pro Max (48EE985A-39A6-426C-88A4-AA1E4AFA0133) (Shutdown)
iPhone SE (2nd generation) (48B78183-AFD7-4832-A80E-AF70844222BA) (Shutdown)
iPad Pro (9.7-inch) (2DEF27C4-6A18-4477-AC7F-FB31CCCB3960) (Shutdown)
iPad (7th generation) (36A4AF6B-1232-4BCB-B74F-226E025225E4) (Shutdown)
iPad Pro (11-inch) (2nd generation) (79391BD7-0E55-44C8-B1F9-AF92A1D57274) (Shutdown)
iPad Pro (12.9-inch) (4th generation) (ED90A31F-6B20-4A6B-9EE9-CF22C01E8793) (Shutdown)
iPad Air (3rd generation) (41AD1CF7-CB0D-4F18-AB1E-6F8B6261AD33) (Shutdown)
-- tvOS 13.4 --
Apple TV 4K (51925935-97F4-4242-902F-041F34A66B82) (Shutdown)
-- watchOS 6.2 --
Apple Watch Series 5 - 40mm (7C50F2E9-A52B-4E0D-8B81-A811FE995502) (Shutdown)
Apple Watch Series 5 - 44mm (F7D8C256-DC9F-4FDC-8E65-63275C222B87) (Shutdown)
Select Simulator string without ID here is example.
iPad Pro (12.9-inch) (4th generation)
Final command
iPhone
• iPhone 6s
react-native run-ios --simulator="iPhone 6s"
• iPhone 8
react-native run-ios --simulator="iPhone 8"
• iPhone 8 Plus
react-native run-ios --simulator="iPhone 8 Plus"
• iPhone SE (2nd generation)
react-native run-ios --simulator="iPhone SE (2nd generation)"
iPad
• iPad Pro (12.9-inch) 4th generation
react-native run-ios --simulator="iPad Pro (12.9-inch) (4th generation)"
• iPad Air (3rd generation)
react-native run-ios --simulator="iPad Air (3rd generation)"
• iPad (7th generation)
react-native run-ios --simulator="iPad (7th generation)"

ios simulator doesn't start black screen invalid device state

ios simulator doesn't start - black screen,
xcode display 'invalid device state' when running the simulator
also happens when simulator starts from Spotlight
tried:
restart mac/xcode/simulator
reset content and settings
$ xcrun simctl list
== Device Types ==
iPhone 4s (com.apple.CoreSimulator.SimDeviceType.iPhone-4s)
iPhone 5 (com.apple.CoreSimulator.SimDeviceType.iPhone-5)
iPhone 5s (com.apple.CoreSimulator.SimDeviceType.iPhone-5s)
iPhone 6 Plus (com.apple.CoreSimulator.SimDeviceType.iPhone-6-Plus)
iPhone 6 (com.apple.CoreSimulator.SimDeviceType.iPhone-6)
iPad 2 (com.apple.CoreSimulator.SimDeviceType.iPad-2)
iPad Retina (com.apple.CoreSimulator.SimDeviceType.iPad-Retina)
iPad Air (com.apple.CoreSimulator.SimDeviceType.iPad-Air)
Resizable iPhone (com.apple.CoreSimulator.SimDeviceType.Resizable-iPhone)
Resizable iPad (com.apple.CoreSimulator.SimDeviceType.Resizable-iPad)
== Runtimes ==
iOS 8.3 (8.3 - 12F69) (com.apple.CoreSimulator.SimRuntime.iOS-8-3)
== Devices ==
-- iOS 8.3 --
iPhone 4s (6EFCAF10-4208-4A5E-B956-500AC64E4F78) (Booted)
iPhone 5 (3111A1E3-1950-44CF-9E77-5862AF8D3C0A) (Shutdown)
iPhone 5s (C8D57731-039E-41DE-8097-A8AF7A4B8778) (Shutdown)
iPhone 6 Plus (42B3FFAB-6718-44E4-9374-9C6A91D91AC2) (Shutdown)
iPhone 6 (765AD568-D63E-41F2-822E-6A7DF22E5F61) (Shutdown)
iPad 2 (28339A10-7624-46AA-9659-F563F9D70958) (Shutdown)
iPad Retina (226EB488-0ECC-4166-BAB5-E787C2EC23B4) (Shutdown)
iPad Air (EE9742AC-FFE4-43E3-B7A7-FCFB5E60137D) (Shutdown)
Resizable iPhone (6A94AFC8-C862-4984-94B5-E13FCADBA9DC) (Shutdown)
Resizable iPad (59E84767-46C5-4A4C-A9D5-E2C4B0600FC2) (Shutdown)
device stuck in booted state
tried
xcrun simctl erase all
version: mac 10.10.3, xcode 6.3.2, simulator 8.3
additional info: yesterday before I finished work it was working with no problems, no change made to anything - just tried to run it from skretch this morning.
Trying to upgrade xcode - it is stuck on waiting for 1 day now...
Every day brings a new Xcode issue, is this one solvable? except for throwing another 2000 euro on a new mac
Edit:
Upgrade solved this issue - but just for a few days, no it's back to black.
new version is Version 6.4 (6E35b)
Notes about upgrade:
upgrade from App Store -> purchased tab
don't try to pause the upgrade, if you do and the process stuck on waiting see this https://apple.stackexchange.com/questions/152934/os-x-yosemite-xcode-update-stuck-on-waiting
download can take about 10-20 hours

My app doesn't support iPhone 4s & 5 on the App Store?

I have just updated a new version of my app and its not supporting iPhone 4s & 5.
From the App Store:
Compatibility: Requires iOS 8.0 or later. Compatible with iPhone 5s, iPhone 6, iPhone 6 Plus, iPhone 6s, iPhone 6s Plus, iPad Air, iPad
Air Wi-Fi + Cellular, iPad mini 2, iPad mini 2 Wi-Fi + Cellular, iPad
Air 2, iPad Air 2 Wi-Fi + Cellular, iPad mini 3, iPad mini 3 Wi-Fi +
Cellular, iPad mini 4, iPad mini 4 Wi-Fi + Cellular, iPad Pro, iPad
Pro Wi-Fi + Cellular, and iPod touch (6th generation).
My older version did support all iPhone, iPad and iPod touch.
In Build settings the valid architectures are (for both debug and release): arm64, armv7 and armv7s
Under required device capabilities I had armv7. My simulators show iPhone 4 & 5 and it runs great.
How do I fix this?
Thanks in advance
So I found the answer to my question.
When I archived my app I had to select "iOS Device" and not archiving for a device that's plugged in at the time.
Source: https://stackoverflow.com/a/24149087/2053537
Check your info.plist file for items listed under "require device capabilities" It's possible that something has crept into this array that requires iPhone 5S+ to run.
Build Settings -> Build Active Architecture Only (Release) = No

How to determine device type from `instruments -s devices`

By running instruments -s devices, you get a list of connected devices as well as virtual simulator devices:
Known Devices:
your.mac [uuid]
Physical Device 1 (9.1) [uuid] <--- unknown device type
Physical Device 2 (9.0) [uuid] <--- unknown device type
Apple TV 1080p (9.0) [uuid]
Apple Watch - 38mm (2.0) [uuid]
Apple Watch - 38mm (2.0) [uuid]
Apple Watch - 42mm (2.0) [uuid]
Apple Watch - 42mm (2.0) [uuid]
iPad 2 (9.1) [uuid]
iPad Air (9.1) [uuid]
iPad Air 2 (9.1) [uuid]
iPad Pro (9.1) [uuid]
iPad Retina (9.1) [uuid]
iPhone 4s (9.1) [uuid]
iPhone 5 (9.1) [uuid]
iPhone 5s (9.1) [uuid]
iPhone 6 (9.1) [uuid]
iPhone 6 Plus (9.1) [uuid]
iPhone 6s (9.1) [uuid]
iPhone 6s (9.1) + Apple Watch - 38mm (2.0) [uuid]
iPhone 6s Plus (9.1) [uuid]
iPhone 6s Plus (9.1) + Apple Watch - 42mm (2.0) [uuid]
The problem is that I can't tell what kind of device is listed on the physical devices. The only thing you really get is the OS version, but there's no way to use this since iOS and tvOS versions are so similar.
Is there any way to lookup a device type based off of a UUID? Or another way to list devices + device types?
Note: Using xcrun simctl doesn't do me any good since I don't care about the simulator, just the physical devices that are connected.

Possible to programatically reset the simulator in test code?

I'm running some test code on the simulator but need to reset the simulator contents each time before runs to make sure the data stored and cached by the app during execution is removed before each re-run of the test cases.
Is there a way to do this from within the tests?
You can use simctl to reset your simulators from the command line, which you could use in a script in your actions to run before a test scheme, but not individual test cases. You need to install the xcode command line tools
to reset the simulator use :
xcrun simctl erase <simulator device id>
to get the device ID you use :
$ xcrun simctl list devices
== Devices ==
-- iOS 10.2 --
iPhone 5 (D226CF12-6782-4D7D-9C00-2D662CF4022C) (Shutdown)
iPhone 5s (34E0E0F8-3429-4D91-B038-ECF4FD0F3311) (Shutdown)
iPhone 6 (9C772A68-34E3-4F3F-981C-543DE6D5D985) (Shutdown)
iPhone 6 Plus (7848A50E-BFB5-4F19-BB31-4A56CA78AA2C) (Shutdown)
iPhone 6s (12CF89BA-C8B2-4837-B4EB-FB24DFF1622C) (Shutdown)
iPhone 6s Plus (3EE6CA84-8F12-4A5E-A31D-EF4BF3CCBDB2) (Shutdown)
iPhone 7 (1EB3CE5D-849C-491C-9CAA-5E97B1BD89CE) (Booted)
iPhone 7 Low Disk Space (6CCF4C7A-606B-40B7-A8D8-DF8B3CB119CB) (Shutdown)
iPhone 7 Plus (94FEFD36-6EFF-4762-BD21-79B1F958F6C6) (Shutdown)
iPhone SE (E8E8ECEB-34C0-44F0-B92E-57DCA91024F1) (Shutdown)
iPad Retina (0DA5BF39-3DC7-49B3-BE9B-2FA756FCA725) (Shutdown)
iPad Air (DAB9C2D3-8EBC-41DC-9C2D-0ECEC1D2FAE3) (Shutdown)
iPad Air 2 (1E2DA170-5C2E-413C-831B-FA65524643D3) (Shutdown)
iPad Pro (9.7 inch) (99F931A9-0708-4637-9294-6420DC7A149C) (Shutdown)
iPad Pro (12.9 inch) (08CD02EB-C44A-4183-961A-EED89FF1C225) (Shutdown)
-- tvOS 10.1 --
Apple TV 1080p (7EE393F2-C83E-467F-9802-3E5BFE7C2CA9) (Shutdown)
-- watchOS 3.1 --
Apple Watch - 38mm (B8969533-D7CD-462E-9E76-511C08E8CC8E) (Shutdown)
Apple Watch - 42mm (E16167D9-1007-438B-8812-CD97CE6ABECA) (Shutdown)
Apple Watch Series 2 - 38mm (F59C0BB1-B4D0-47DD-B927-1BFD78DD78C0) (Shutdown)
Apple Watch Series 2 - 42mm (7FE3AADD-94AB-46B9-A057-78F20F030999) (Shutdown)
Device IDs remain constant I think until they're deleted or recreated, it would probably be possible to retrieve the device id of the booted simulator using some scripting magik (which I haven't yet worked out), the current active simulator is always marked as (Booted)
You can also use simctl to create custom simulators, just use xcrun simctl to list all the stuff it does.
You could use LUA script to do this with your automated testing. Have a look at http://www.coronalabs.com/blog/2011/08/11/automated-testing-on-mobile-devices-part4/ for detailed instructions.
Basically you will have lua use events to reset it.

Resources