Skip to content

Commit b98ffdc

Browse files
Add PrivacyInfo.xcprivacy to plugin template (#148485)
Adds an empty privacy manifest, and commented out code to include it in the build, to the plugin template. This will make it much easier to explain how to add a privacy manifest in plugin docs, since instead of explaining the format of the file from scratch and providing example code to inculde it, we can just instruct people to add entries to an exisitng file and then uncomment a line or two. This will also make it much easier to figure out from the template output itself how to add support for people who don't find the documentation. Part of flutter/flutter#131940 Fixes flutter/flutter#140013
1 parent 3a27301 commit b98ffdc

File tree

9 files changed

+73
-5
lines changed

9 files changed

+73
-5
lines changed

packages/flutter_tools/templates/plugin/ios-objc.tmpl/projectName.podspec.tmpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,15 @@ Pod::Spec.new do |s|
2626

2727
# Flutter.framework does not contain a i386 slice.
2828
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
29+
30+
# If your plugin requires a privacy manifest, for example if it uses any
31+
# required reason APIs, update the PrivacyInfo.xcprivacy file to describe your
32+
# plugin's privacy impact, and then uncomment this line. For more information,
33+
# see https://developer.apple.com/documentation/bundleresources/privacy_manifest_files
34+
{{#withSwiftPackageManager}}
35+
# s.resource_bundles = {'{{projectName}}_privacy' => ['{{projectName}}/Sources/{{projectName}}/PrivacyInfo.xcprivacy']}
36+
{{/withSwiftPackageManager}}
37+
{{^withSwiftPackageManager}}
38+
# s.resource_bundles = {'{{projectName}}_privacy' => ['Resources/PrivacyInfo.xcprivacy']}
39+
{{/withSwiftPackageManager}}
2940
end

packages/flutter_tools/templates/plugin/ios-swift.tmpl/projectName.podspec.tmpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,15 @@ Pod::Spec.new do |s|
2525
# Flutter.framework does not contain a i386 slice.
2626
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' }
2727
s.swift_version = '5.0'
28+
29+
# If your plugin requires a privacy manifest, for example if it uses any
30+
# required reason APIs, update the PrivacyInfo.xcprivacy file to describe your
31+
# plugin's privacy impact, and then uncomment this line. For more information,
32+
# see https://developer.apple.com/documentation/bundleresources/privacy_manifest_files
33+
{{#withSwiftPackageManager}}
34+
# s.resource_bundles = {'{{projectName}}_privacy' => ['{{projectName}}/Sources/{{projectName}}/PrivacyInfo.xcprivacy']}
35+
{{/withSwiftPackageManager}}
36+
{{^withSwiftPackageManager}}
37+
# s.resource_bundles = {'{{projectName}}_privacy' => ['Resources/PrivacyInfo.xcprivacy']}
38+
{{/withSwiftPackageManager}}
2839
end
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>NSPrivacyTrackingDomains</key>
6+
<array/>
7+
<key>NSPrivacyAccessedAPITypes</key>
8+
<array/>
9+
<key>NSPrivacyCollectedDataTypes</key>
10+
<array/>
11+
<key>NSPrivacyTracking</key>
12+
<false/>
13+
</dict>
14+
</plist>

packages/flutter_tools/templates/plugin_swift_package_manager/ios-objc.tmpl/projectName.tmpl/Package.swift.tmpl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ let package = Package(
1717
name: "{{projectName}}",
1818
dependencies: [],
1919
resources: [
20-
.process("Resources"),
20+
// If your plugin requires a privacy manifest, for example if it uses any required
21+
// reason APIs, update the PrivacyInfo.xcprivacy file to describe your plugin's
22+
// privacy impact, and then uncomment these lines. For more information, see
23+
// https://developer.apple.com/documentation/bundleresources/privacy_manifest_files
24+
// .process("PrivacyInfo.xcprivacy"),
25+
26+
// If you have other resources that need to be bundled with your plugin, refer to
27+
// the following instructions to add them:
28+
// https://developer.apple.com/documentation/xcode/bundling-resources-with-a-swift-package
2129
],
2230
cSettings: [
2331
.headerSearchPath("include/{{projectName}}"),

packages/flutter_tools/templates/plugin_swift_package_manager/ios-swift.tmpl/projectName.tmpl/Package.swift.tmpl

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ let package = Package(
1717
name: "{{projectName}}",
1818
dependencies: [],
1919
resources: [
20-
.process("Resources"),
20+
// If your plugin requires a privacy manifest, for example if it uses any required
21+
// reason APIs, update the PrivacyInfo.xcprivacy file to describe your plugin's
22+
// privacy impact, and then uncomment these lines. For more information, see
23+
// https://developer.apple.com/documentation/bundleresources/privacy_manifest_files
24+
// .process("PrivacyInfo.xcprivacy"),
25+
26+
// If you have other resources that need to be bundled with your plugin, refer to
27+
// the following instructions to add them:
28+
// https://developer.apple.com/documentation/xcode/bundling-resources-with-a-swift-package
2129
]
2230
)
2331
]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>NSPrivacyTrackingDomains</key>
6+
<array/>
7+
<key>NSPrivacyAccessedAPITypes</key>
8+
<array/>
9+
<key>NSPrivacyCollectedDataTypes</key>
10+
<array/>
11+
<key>NSPrivacyTracking</key>
12+
<false/>
13+
</dict>
14+
</plist>

packages/flutter_tools/templates/plugin_swift_package_manager/ios.tmpl/projectName.tmpl/Sources/projectName.tmpl/Resources/.gitkeep

Whitespace-only changes.

packages/flutter_tools/templates/template_manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,14 +337,15 @@
337337
"templates/plugin_cocoapods/ios-objc.tmpl/Classes/pluginClass.m.tmpl",
338338
"templates/plugin_cocoapods/ios-swift.tmpl/Classes/pluginClass.swift.tmpl",
339339
"templates/plugin_cocoapods/ios.tmpl/Assets/.gitkeep",
340+
"templates/plugin_cocoapods/ios.tmpl/Resources/PrivacyInfo.xcprivacy",
340341
"templates/plugin_cocoapods/macos.tmpl/Classes/pluginClass.swift.tmpl",
341342

342343
"templates/plugin_swift_package_manager/ios-objc.tmpl/projectName.tmpl/Sources/projectName.tmpl/include/projectName.tmpl/pluginClass.h.tmpl",
343344
"templates/plugin_swift_package_manager/ios-objc.tmpl/projectName.tmpl/Sources/projectName.tmpl/pluginClass.m.tmpl",
344345
"templates/plugin_swift_package_manager/ios-objc.tmpl/projectName.tmpl/Package.swift.tmpl",
345346
"templates/plugin_swift_package_manager/ios-swift.tmpl/projectName.tmpl/Sources/projectName.tmpl/pluginClass.swift.tmpl",
346347
"templates/plugin_swift_package_manager/ios-swift.tmpl/projectName.tmpl/Package.swift.tmpl",
347-
"templates/plugin_swift_package_manager/ios.tmpl/projectName.tmpl/Sources/projectName.tmpl/Resources/.gitkeep",
348+
"templates/plugin_swift_package_manager/ios.tmpl/projectName.tmpl/Sources/projectName.tmpl/PrivacyInfo.xcprivacy",
348349
"templates/plugin_swift_package_manager/macos.tmpl/projectName.tmpl/Sources/projectName.tmpl/Resources/.gitkeep",
349350
"templates/plugin_swift_package_manager/macos.tmpl/projectName.tmpl/Sources/projectName.tmpl/pluginClass.swift.tmpl",
350351
"templates/plugin_swift_package_manager/macos.tmpl/projectName.tmpl/Package.swift.tmpl",

packages/flutter_tools/test/commands.shard/permeable/create_test.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,6 +705,7 @@ void main() {
705705
'example/ios/Runner/Runner-Bridging-Header.h',
706706
'example/lib/main.dart',
707707
'ios/Classes/FlutterProjectPlugin.swift',
708+
'ios/Resources/PrivacyInfo.xcprivacy',
708709
'lib/flutter_project.dart',
709710
],
710711
unexpectedPaths: <String>[
@@ -726,7 +727,7 @@ void main() {
726727
<String>[
727728
'ios/flutter_project/Package.swift',
728729
'ios/flutter_project/Sources/flutter_project/FlutterProjectPlugin.swift',
729-
'ios/flutter_project/Sources/flutter_project/Resources/.gitkeep',
730+
'ios/flutter_project/Sources/flutter_project/PrivacyInfo.xcprivacy',
730731
'macos/flutter_project/Package.swift',
731732
'macos/flutter_project/Sources/flutter_project/FlutterProjectPlugin.swift',
732733
'macos/flutter_project/Sources/flutter_project/Resources/.gitkeep',
@@ -755,7 +756,7 @@ void main() {
755756
'ios/flutter_project/Package.swift',
756757
'ios/flutter_project/Sources/flutter_project/include/flutter_project/FlutterProjectPlugin.h',
757758
'ios/flutter_project/Sources/flutter_project/FlutterProjectPlugin.m',
758-
'ios/flutter_project/Sources/flutter_project/Resources/.gitkeep',
759+
'ios/flutter_project/Sources/flutter_project/PrivacyInfo.xcprivacy',
759760
],
760761
unexpectedPaths: <String>[
761762
'ios/Classes/FlutterProjectPlugin.swift',

0 commit comments

Comments
 (0)