Issue
I want to run/test (not automated test) my Flutter app on a real iPhone and Android phone during development. However, Flutter docs seem to only document how to do it with the iOS simulator or Android emulators.
I think it's already a no-brainer for iOS/Android devs but I am neither and Flutter is my first foray into mobile development.
Is there any link to a beginner's guide somewhere on how to develop while running it on a real device (with all of Flutter's live-reload goodness)?
Additional context
- I'm a web developer.
- I use Android Studio and VS Code.
- I work on a MacBook.
Solution
For Android, this is pretty easy:
- Enable Developer options and USB debugging on your device. This varies slightly by Android version, but the short version is you tap on the Device Build Number 7 times. Then a "Developer Options" option comes up and you can click "enable USB Debugging." See the linked Android documentation for the most up-to-date instructions.
- Then plug your phone into your computer with a USB cable. You'll probably see some popup on your phone asking if you want to allow USB debuggng with that computer. Say "yes".
- Run Flutter just like you would if you had a simulator running.
Using the right cable can make a difference. If the device is charging but nothing happens, try using another cable, preferably the one that came with the device. A notification on the device (e.g. "connected as a media device") and on Windows (e.g. "Device connected and ready to go") are indications that the USB connection is working. You should then be able to see the device on the CLI with:
flutter devices
For iOS this is a little more complicated because you need an Apple ID or to sign up for a "Developer Account":
- Open XCode, then open "Preferences>Accounts". Sign in with your ID.
- "Manage Certificates" > click on the "+" sign and select "iOS Development".
- Plug your device into your machine. Find your device in the drop down (Window > Organizer).
- Below the Team pop-up menu, click Fix Issue.
- In Xcode, click the Run button.
(in subsequent runs, you can deploy to the iOS device with Android Studio, VS Code, or any other IDE of choice, you just need to set up that certificate the first time with Xcode. Here's Apple's documentation on setting up Xcode to run a physical device.)
Answered By - fortuna
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.