How do I run/test my Flutter app on a real device?

后端 未结 1 581
忘掉有多难
忘掉有多难 2020-12-03 04:53

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 t

相关标签:
1条回答
  • 2020-12-03 05:28

    For Android, this is pretty easy:

    1. 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.
    2. 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".
    3. Run Flutter just like you would if you had a simulator running.

    For iOS this is a little more complicated because you need an Apple ID or to sign up for a "Developer Account":

    1. Open XCode, then open "Preferences>Accounts". Sign in with your ID.
    2. "Manage Certificates" > click on the "+" sign and select "iOS Development".
    3. Plug your device into your machine. Find your device in the drop down (Window > Organizer).
    4. Below the Team pop-up menu, click Fix Issue.
    5. 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.)

    0 讨论(0)
提交回复
热议问题