Skip to content

Add to app iOS 14 Info.plist network permissions#554

Merged
jmagman merged 1 commit intoflutter:masterfrom
jmagman:a2a-bonjour
Sep 26, 2020
Merged

Add to app iOS 14 Info.plist network permissions#554
jmagman merged 1 commit intoflutter:masterfrom
jmagman:a2a-bonjour

Conversation

@jmagman
Copy link
Member

@jmagman jmagman commented Sep 26, 2020

Background

iOS 14 requires NSBonjourServices in an app's Info.plist to prompt the user to give local network permissions to the app. The Flutter engine need this permission set to _dartobservatory._tcp in order to publish the dart VM service (observatory) port (debug/profile only), so the host tooling can discover the port and connect. Optionally, NSLocalNetworkUsageDescription can also be set to customize the permission prompt.

flutter tooling automatically handles this as of flutter/flutter#64988, but add-to-app hosts must add these keys manually. See also flutter/flutter#63893 and https://flutter.dev/docs/development/ios-14#debugging-flutter.

Description

Updated the three add_to_app host apps. The following breakdown uses IOSFullScreen as an example.

  1. Renamed app Info.plist to Info-Debug.plist. Made a copy of it called Info-Release.plist and added the second plist to the Xcode project.

Screen Shot 2020-09-25 at 9 15 36 PM

  1. In Info-Debug.plist only added
<key>NSBonjourServices</key>
<array>
	<string>_dartobservatory._tcp</string>
</array>
<key>NSLocalNetworkUsageDescription</key>
<string>Allow Flutter tools on your computer to connect and debug your application. This prompt will not appear on release builds.</string>

Note: Xcode's plist editor displays NSBonjourServices as "Bonjour services" and NSLocalNetworkUsageDescription as "Privacy - Local Network Usage Description"
Screen Shot 2020-09-25 at 9 33 57 PM

  1. Changed app target > Build Settings > Info.plist File (INFOPLIST_FILE) to IOSFullScreen/Info-$(CONFIGURATION).plist. This will resolve to the path IOSFullScreen/Info-Debug.plist in Debug and IOSFullScreen/Info-Release.plist

Screen Shot 2020-09-25 at 9 17 10 PM

Screen Shot 2020-09-25 at 9 17 15 PM

Launching the app in debug now shows the local network permissions pop up:
flutter_01

Additionally, I added the missing IOSFullScreen scheme file so the app can be launched from Xcode.

@jmagman jmagman requested review from redbrogdon and xster September 26, 2020 04:47
@jmagman jmagman self-assigned this Sep 26, 2020
Comment on lines +44 to +49
<key>NSBonjourServices</key>
<array>
<string>_dartobservatory._tcp</string>
</array>
<key>NSLocalNetworkUsageDescription</key>
<string>Allow Flutter tools on your computer to connect and debug your application. This prompt will not appear on release builds.</string>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an exact copy of Info-Release.plist except for these two keys.

Copy link
Member

@xster xster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

The screenshots: 👏👍👌🙌💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants