Flutter iOS 14.0 build error: Failed to register observatory port with mDNS

Viewed 9727

I am implementing a mobile app using Flutter. When I try to run the app on iOS real device from Xcode, I get this error:

[VERBOSE-2:FlutterObservatoryPublisher.mm(115)] Failed to register observatory port with mDNS.

The app runs fine as long as the device is connected to the Mac and running from Xcode. But when I try to open it from the device Home Screen directly, it crashes.

This issue happens on iOS 14.0 and higher. It works fine on iOS 13.x.

5 Answers

add this property info.plist

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

I was able to fix it. This is how I did it.

For you to fix this error. open the iPhone simulator then run your flutter project. then go to System Preferences > Security & Privacy > General Tab. You need to give permission to iproxy(I can't remember the file name but you need to give that file permission to run). After it has successfully run on your simulator. Plug your iPhone follow the steps again.

It's a few days I'm dealing (without a solution) with this problem. If you have any useful information, here you can share it (or, maybe, find it).

At the moment, I'm working on a workaround, that I will share in that thread ASAP.

I debug an (object-c based) flutter project, I like to launch it in Xcode, I find it more fast launching app in Xcode than 'flutter run' command in terminal. then I like to 'flutter attach' to it for hot reload.

I encountered this error very often.

It seems to touch the AppDelegate.m file forcing it to be re-compiled can fix this problem....

Here is the original documentation

On iOS 14 and higher, enable the Dart multicast DNS service in the Debug version of your app to add debugging functionalities such as hot-reload and DevTools via flutter attach.

In Info.plist only add the key NSBonjourServices and set the value to an array with the string _dartobservatory._tcp. Note Xcode will display this as “Bonjour services”.

Optionally, add the key NSLocalNetworkUsageDescription set to your desired customized permission dialog text.

The original documentation mentions that this shouldn't be used in the Release version and also provides some instructions how to enable only for Debug releases.

Warning: This service must not be enabled in the Release version of your app, or you may experience App Store rejections.

Related