iOS设备Flutter attach不上问题与flutter hot restart ios工程配置

1,641 阅读2分钟

iOS设备的mDNS查询失败解决方案 The mDNS query for an attached iOS device failed. flutter hot restart ios工程配置

The mDNS query for an attached iOS device failed. It may be necessary to disable the "Personal Hotspot" on the device, and to ensure that the "Disable unless needed" setting is unchecked under System Preferences > Network > iPhone USB. See github.com/flutter/flu… for details. Waiting for a connection from Flutter on iPhone6hu...

检查flutter产物版本

检查应用程序的构建产物是否为调试版本,而不是发布版本。

重新集成debug版本flutter产物,重新pod install之后编译app

检查ios工程配置

1,App端Info.plist是否添加了添加了Bonjour 服务 和隐私 - 本地网络使用描述

在 iOS 14 及更高版本中,在iOS 应用的DEBUG版本中启用 Dart 多播 DNS 服务 docs.flutter.cn/add-to-app/…

	<key>NSBonjourServices</key>
	<array>
		<string>_dartobservatory._tcp</string>
	</array>

以及本地网络权限(可选):

<key>NSLocalNetworkUsageDescription</key> 
<string>需要访问本地网络权限</string>

其它可能问题(一般不会有问题)

1,xcode删除设备重新连接

image.png

2,重启xcode, clean项目,重启android studio,重新 pub get, 重启电脑,重启手机

3,关闭手机热点

4,修改电脑网络设置如下:

I fixed it. I noticed a (new?) setting in macOS network settings on the iPhone USB interface: "Disable until needed". It was checked by default: image.png

启动了多个flutter deubg app

多个flutter app同时被运行中, 制定attach args参数 使用--app-id指定当前app

image.png

如果之前都attach 没问题,如上这些没有修改

检查flutter 产物和本地flutter 版本是否一致

flutter 产物打包可能是在打包机上进行,本地开发有多个flutter版本的环境

那么可能是忘记了两个重要的问题:

因为我们通常用的flutter 混合开发模式, flutter产物被组件集成到app端。

1,检查 flutter 版本是否一致, App的 Flutter产物库的版本和电脑flutter环境版本是否一致 比如app端是2.5.3 电脑上flutter版本是3.0.5

2,检查 app端产物是否debug版本的。 非release产物。

成功 attach