-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
flutter/engine#6533 added the ability to have iOS apps advertise the Dart observatory port over mDNS. The following command on macOS can display that information:
dns-sd -Z _dartobservatory._tcpwhich has output similar to the following:
Browsing for _dartobservatory._tcp
DATE: ---Tue 16 Oct 2018---
11:00:09.974 ...STARTING...
; To direct clients to browse a different domain, substitute that domain in place of '@'
lb._dns-sd._udp PTR @
; In the list of services below, the SRV records will typically reference dot-local Multicast DNS names.
; When transferring this zone file data to your unicast DNS server, you'll need to replace those dot-local
; names with the correct fully-qualified (unicast) domain name of the target host offering the service.
_dartobservatory._tcp PTR com\.example\.iosTestMod@dans-iphone\.local._dartobservatory._tcp
com\.example\.iosTestMod@dans-iphone\.local._dartobservatory._tcp SRV 0 0 49198 Dans-iPhone.local. ; Replace with unicast FQDN of target host
com\.example\.iosTestMod@dans-iphone\.local._dartobservatory._tcp TXT ""
indicating the observatory port is running on 49198 from the SRV record. Running flutter attach --debug-port 49198 will successfully attach to that observatory port.
Unfortunately, dns-sd is not suitable for scripting (it never "finishes" processing, the output and command flags are explicitly not guaranteed), and we'd like to avoid adding more Ruby/Python/etc. scripts to support this.
Writing the mDNS query in Dart (particularly on macOS) is currently blocked by dart-lang/sdk#34799. A patch has been created, and using that source I've been able to successfully query the service using Dart on macOS.
Once that lands, we should be able to either implement mDNS in the Dart SDK (e.g. in dart:io), or at least have a simple client in the flutter_tools package that can discover the port automatically for flutter attach without any additional steps.