如何在真实设备上运行/测试Flutter应用程序? [英] How do I run/test my Flutter app on a real device?

查看:335
本文介绍了如何在真实设备上运行/测试Flutter应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在开发过程中,我想在真实的iPhone和Android手机上运行/测试(而非自动测试)我的Flutter应用程序.但是,Flutter的文档似乎只记录了如何使用iOS模拟器或Android模拟器来做到这一点.

我认为对于iOS/Android开发人员而言,这已经是不费吹灰之力了,但我俩都不是,而Flutter是我第一次涉足移动开发.

在真正的设备上运行时(具有Flutter的所有实时重载功能),是否有任何指向初学者指南的链接?

其他上下文

  • 我是网络开发人员.
  • 我使用Android Studio和VS Code.
  • 我在MacBook上工作.

解决方案

对于Android,这非常简单:

  1. 在设备上启用开发人员选项和USB调试.这取决于Android版本,但略有不同,但短版是您点击Device Build Number 7次.然后出现开发人员选项"选项,您可以单击启用USB调试".有关最新的说明,请参见链接的Android文档.
  2. 然后使用USB电缆将手机插入计算机.您可能会在手机上看到一些弹出窗口,询问是否要允许该计算机进行USB调试.说是".
  3. 像运行模拟器一样,运行Flutter.

对于iOS,这要复杂一些,因为您需要Apple ID或注册"开发者帐户":

  1. 打开XCode,然后打开首选项>帐户".使用您的ID登录.
  2. 管理证书">单击"+"号,然后选择"iOS开发".
  3. 将设备插入计算机.在下拉菜单(窗口>管理器)中找到您的设备.
  4. 在团队"弹出菜单下,单击修复问题".
  5. 在Xcode中,单击运行"按钮.

(在随后的运行中,您可以使用Android Studio,VS Code或任何其他选择的IDE部署到iOS设备,只需在第一次使用Xcode设置该证书即可. 解决方案

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.)

这篇关于如何在真实设备上运行/测试Flutter应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆