简体   繁体   中英

How do I run Flutter in multiple iOS Simulators

Environment:

[✓] Flutter (Channel master, 1.19.0-2.0.pre.214, on Mac OS X 10.15.4 19E287, locale en-PH)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
[✓] Chrome - develop for the web
[✓] Android Studio (version 3.6)
[✓] VS Code (version 1.45.1)
[✓] Connected device (2 available)

When I run flutter devices all I get are the following:

Web Server • web-server • web-javascript • Flutter Tools
Chrome     • chrome     • web-javascript • Google Chrome 83.0.4103.61
<and my physical devices which I ommited>

Now when I run flutter emulators , I get the built-in apple_ios_simulator and the Android emulator which I created:

apple_ios_simulator • iOS Simulator • Apple  • ios
Pixel_API_R         • Pixel API R   • Google • android

Creating an Android emulator is easy, I can just add as much AVDs I want using Android studio and they'll show up every time I call flutter emulators .

How do I do that for iOS simulators?

Ok, apparently iOS Simulators are not regarded as flutter emulators . For the life of me, I could not find any documentation regarding this so here it goes.

The iOS Simulator can be run with flutter emulators --launch apple_ios_simulator

After launching this when you run flutter devices it will appear as a device.

3 connected devices:

iPhone 11                  • DCDA3304-2E80-4BCD-B0D5-968C2EBD2FA3 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-13-5 (simulator)
Web Server                 • web-server                           • web-javascript • Flutter Tools
Chrome                     • chrome                               • web-javascript • Google Chrome 83.0.4103.61

Then just run another simulator via the Simulator app

在此处输入图像描述

Run flutter devices once again to check if another iOS Simulator device has showed up

4 connected devices:

iPhone 11                  • DCDA3304-2E80-4BCD-B0D5-968C2EBD2FA3 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-13-5 (simulator)
iPhone SE (2nd generation) • 59D9A787-E68B-4CE1-8CDB-2A5D3CBF0093 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-13-5 (simulator)
Web Server                 • web-server                           • web-javascript • Flutter Tools
Chrome                     • chrome                               • web-javascript • Google Chrome 83.0.4103.61

And from there you can just run flutter run -d all .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM