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

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

问题描述

我想在开发过程中在真正的 iPhone 和 Android 手机上运行/测试(不是自动化测试)我的 Flutter 应用程序.但是,Flutter 文档似乎只记录了如何使用 iOS 模拟器或 Android 模拟器进行操作.

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.

我认为对于 iOS/Android 开发者来说,这已经很简单了,但我两者都不是,而且 Flutter 是我第一次涉足移动开发.

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.

是否有任何指向初学者指南的链接,了解如何在真实设备上运行它时进行开发(具有 Flutter 的所有实时重新加载优点)?

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

附加上下文

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

推荐答案

对于 Android,这很容易:

For Android, this is pretty easy:

  1. 在您的设备上启用开发者选项和 USB 调试.这因 Android 版本而略有不同,但简短版本是您点击设备版本号 7 次.然后出现开发人员选项"选项,您可以单击启用 USB 调试".有关最新说明,请参阅链接的 Android 文档.
  2. 然后使用 USB 数据线将您的手机插入计算机.您可能会在手机上看到一些弹出窗口,询问您是否要允许使用该计算机进行 USB 调试.说是".
  3. 像运行模拟器一样运行 Flutter.
  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.

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

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

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

(在后续运行中,您可以使用 Android Studio、VS Code 或任何其他选择的 IDE 部署到 iOS 设备,您只需在第一次使用 Xcode 设置该证书即可.这是 Apple 的文档 关于设置 Xcode 以运行物理设备.)

(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天全站免登陆