When testing a react native mobile application one would want to view and debug application in different screen sizes and devices. It is essential to test your application for rendering, look and feel, performance and responsiveness. For this developers use iOS and Android simulator and real devices to test their application.
In this article I will show you how to change default iOS Simulator Device version while running a react native mobile application.
Perquisites
- A react native app running on an iOS Simulator
How to change Default iOS Simulator Device
First on all you would like to view which devices are available in your iOS simulator. To see all the available devices you can use:
xcrun simctl list devices
It should list all available devices such as the following:
== Devices == -- iOS 14.5 -- iPhone 8 (6413E436-CCC8-49E7-82A6-F6852E407802) (Booted) iPhone 8 Plus (4F64D80F-527D-4E4A-B9B8-D90CC365EEAD) (Shutdown) iPhone 11 (44724DA8-A27C-421A-9804-8E00BE21BC08) (Shutdown) iPhone 11 Pro (71604D55-AD13-4335-90AE-CB8ED9804DA6) (Shutdown) iPhone 11 Pro Max (3A27B999-4F1B-46F6-B78D-315829C9CA3E) (Shutdown) iPhone SE (2nd generation) (9CA2443A-E112-45D9-8AC2-07A10261D7BD) (Shutdown) iPhone 12 mini (F9108AB0-97AB-4CC2-BA17-E997A172DA3F) (Shutdown) iPhone 12 (4537AF4F-6B73-48C7-89B9-07A01F464A6D) (Shutdown) iPhone 12 Pro (E835D991-CABB-4D3C-A561-D65FCBF37832) (Shutdown) iPhone 12 Pro Max (4E075E7A-ED8B-4FE5-AB77-259F64C19A8B) (Shutdown) iPod touch (7th generation) (5D4D873A-81F0-4724-B4EB-7BED02FDF1A2) (Shutdown) iPad Pro (9.7-inch) (DCF5C63A-6B62-4691-BA87-0F2DE6AC3FB9) (Shutdown) iPad (8th generation) (4AB119C9-7521-4FC9-9882-9C18025DABE6) (Shutdown) iPad (8th generation) (5AB7A297-F4C9-4C91-8CA5-7D5D8341EF58) (Shutdown) iPad Air (4th generation) (E5DD7BC4-B772-42CA-8A17-5FEB7285C4B6) (Shutdown) iPad Pro (11-inch) (3rd generation) (587A8303-DC9A-44A6-9EA1-C9EE5D61F0D6) (Shutdown) iPad Pro (12.9-inch) (5th generation) (0CB1B96E-1632-408A-9AE4-7C062AA3938F) (Shutdown) -- tvOS 14.5 -- Apple TV (69AC75A2-6F04-4C76-826D-C6693DB9D62E) (Shutdown) Apple TV 4K (2nd generation) (7A439C54-64D1-48CC-9765-2E001E5D35C1) (Shutdown) Apple TV 4K (at 1080p) (2nd generation) (75E4660A-72E7-4566-99ED-1A95B23D2851) (Shutdown) -- watchOS 7.4 -- Apple Watch Series 5 - 40mm (16068347-F093-4892-B56E-990770ED99FA) (Shutdown) Apple Watch Series 5 - 44mm (5CF3DF92-2931-47F8-BC20-01FB442D967F) (Shutdown) Apple Watch Series 6 - 40mm (BC3EEBAC-AB3C-4F8C-8B9D-69095364856B) (Shutdown) Apple Watch Series 6 - 44mm (E7F7B2C1-3B2A-4CD2-94C1-68E82C6FA554) (Shutdown)
To change default iOS simulator device to iPhone 11, run
npx react-native run-ios --simulator="iPhone 11"
That’s it.
Conclusion
I have shown you how to change your default iOS simulator device. If you like this articles, kindly comment to let me know. Keep visiting my blog for more articles. :)
This article was inspired by an answer at stackoverflow.
Read next: How to Install Let’s Encrypt (Certbot) on Ubuntu 20.04