From 85abc4462498ad02463751072980493c36dc8244 Mon Sep 17 00:00:00 2001 From: Jenn Magder Date: Wed, 13 Dec 2023 17:37:59 -0800 Subject: [PATCH] Add xcprivacy privacy manifest to iOS framework (flutter/engine#48951) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create a `PrivacyInfo.xcprivacy` (this name is required) plist and move it to the top-level of the iOS framework bundle. `NSPrivacyTracking*` and `NSPrivacyCollectedDataTypes` keys are required, but the values are blank. Apple [now requires](https://developer.apple.com/documentation/bundleresources/privacy_manifest_files) that third-party frameworks must include this manifest to document usage of particular APIs and [how they are used](https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api). > Starting in fall 2023, when you upload a new app or app update to App Store Connect that uses an API (including from third-party SDKs) that requires a reason, you’ll receive a notice if you haven’t provided an approved reason in your app’s privacy manifest. And starting in spring 2024, in order to upload your new app or app update to App Store Connect, you’ll be required to include an approved reason in the app’s privacy manifest which accurately reflects how your app uses the API. https://developer.apple.com/news/?id=z6fu1dcu @stuartmorgan [audited](https://github.com/flutter/flutter/issues/131494#issuecomment-1852718759) the engine and third_party: > * File timestamps: > > * `C617.1` for app state restoration in `FlutterAppDelegate.mm`. > * `0A2A.1` for implementation of the relevant `File` wrappers. > * System boot time: > > * `35F9.1` for various event timing and elapsed time calculations. Note macOS frameworks do not need to declare `NSPrivacyAccessedAPITypes`. I don't think this will require recipe or conductor codesign changes since this is a file copied as a resource into the framework, just as the modulemap and Info.plist aren't referenced anywhere. I'm not quite sure how to test this other than letting it build and generate a `Generate Privacy Report` in a Flutter app in Xcode. There's no where we check that, say, the Info.plist is copied to the right place in Flutter.framework (even in flutter/flutter). When this rolls into the framework I will add a check to [ios_content_validation_test.dart](https://github.com/flutter/flutter/blob/3da9bc169837d223496439b6d5f6b7e1a82d4318/dev/devicelab/bin/tasks/ios_content_validation_test.dart) On this PR the `PrivacyInfo.xcprivacy` was written to the expected location in the Flutter.framework: https://cas-viewer.appspot.com/projects/chromium-swarm/instances/default_instance/blobs/d45cd0809420f08145c7b78ea96cba6e7ea48d8ecfdc8fd2411f82fa65444714/516/tree Fixes https://github.com/flutter/flutter/issues/131494 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style --- .../ci/licenses_golden/licenses_flutter | 1 + .../shell/platform/darwin/ios/BUILD.gn | 11 ++++++ .../ios/framework/PrivacyInfo.xcprivacy | 34 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 engine/src/flutter/shell/platform/darwin/ios/framework/PrivacyInfo.xcprivacy diff --git a/engine/src/flutter/ci/licenses_golden/licenses_flutter b/engine/src/flutter/ci/licenses_golden/licenses_flutter index d3da593ae9..e11479548c 100644 --- a/engine/src/flutter/ci/licenses_golden/licenses_flutter +++ b/engine/src/flutter/ci/licenses_golden/licenses_flutter @@ -9343,6 +9343,7 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterPlugin FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterPluginAppLifeCycleDelegate.h FILE: ../../../flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h FILE: ../../../flutter/shell/platform/darwin/ios/framework/Info.plist +FILE: ../../../flutter/shell/platform/darwin/ios/framework/PrivacyInfo.xcprivacy FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate.mm FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegateTest.mm FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterAppDelegate_Test.h diff --git a/engine/src/flutter/shell/platform/darwin/ios/BUILD.gn b/engine/src/flutter/shell/platform/darwin/ios/BUILD.gn index ad924acfbe..bfcb4fcbb7 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/BUILD.gn +++ b/engine/src/flutter/shell/platform/darwin/ios/BUILD.gn @@ -373,6 +373,15 @@ copy("copy_framework_module_map") { outputs = [ "$_flutter_framework_dir/Modules/module.modulemap" ] } +# Copy privacy manifest. This file is required by Apple for third-party SDKs, +# and documents engine and third_party usage of timestamps and boot time APIs. +# See https://developer.apple.com/documentation/bundleresources/privacy_manifest_files +copy("copy_framework_privacy_manifest") { + visibility = [ ":*" ] + sources = [ "framework/PrivacyInfo.xcprivacy" ] + outputs = [ "$_flutter_framework_dir/PrivacyInfo.xcprivacy" ] +} + action("copy_framework_headers") { script = "//flutter/sky/tools/install_framework_headers.py" visibility = [ ":*" ] @@ -415,6 +424,7 @@ shared_library("copy_and_verify_framework_module") { ":copy_framework_headers", ":copy_framework_info_plist", ":copy_framework_module_map", + ":copy_framework_privacy_manifest", ] if (darwin_extension_safe) { @@ -437,6 +447,7 @@ group("universal_flutter_framework") { ":copy_framework_icu", ":copy_framework_info_plist", ":copy_framework_module_map", + ":copy_framework_privacy_manifest", ":copy_license", ] diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/PrivacyInfo.xcprivacy b/engine/src/flutter/shell/platform/darwin/ios/framework/PrivacyInfo.xcprivacy new file mode 100644 index 0000000000..e656417947 --- /dev/null +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/PrivacyInfo.xcprivacy @@ -0,0 +1,34 @@ + + + + + NSPrivacyTracking + + NSPrivacyTrackingDomains + + NSPrivacyCollectedDataTypes + + + + NSPrivacyAccessedAPITypes + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryFileTimestamp + NSPrivacyAccessedAPITypeReasons + + 0A2A.1 + C617.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategorySystemBootTime + NSPrivacyAccessedAPITypeReasons + + 35F9.1 + + + + +