Skip to content

Commit d669ff7

Browse files
cipolleschiphilIip
andauthored
[iOS][Privacy Manifest] Set up privacy manifest for React Native 0.71 (#44281)
* add privacy manifest to pod install Summary: Changelog: [iOS][Added] this creates the RN privacy manifest in the ios build step if user has not created one yet. the reasons have been added for the following APIs: NSPrivacyAccessedAPICategoryFileTimestamp - C617.1: We use fstat and stat in a few places in the C++ layer. We use these to read information about the JavaScript files in RN. NSPrivacyAccessedAPICategoryUserDefaults - CA92.1: We access NSUserDefaults in a few places. 1) To store RTL preferences 2) As part of caching server URLs for developer mode 3) A generic native module that wraps NSUserDefaults NSPrivacyAccessedAPICategorySystemBootTime - 35F9.1: Best guess reason from RR API pulled in by boost Reviewed By: cipolleschi Differential Revision: D53687232 fbshipit-source-id: 6dffb1a6013f8f29438a49752e47ed75c13f4a5c * add privacy manifest to hello world template Summary: Changelog: [iOS][Added] this change will be included in the RN CLI. so all new apps running the RN CLI to get created will get this manifest. the reasons have been added for the following APIs: NSPrivacyAccessedAPICategoryFileTimestamp - C617.1: We use fstat and stat in a few places in the C++ layer. We use these to read information about the JavaScript files in RN. NSPrivacyAccessedAPICategoryUserDefaults - CA92.1: We access NSUserDefaults in a few places. 1) To store RTL preferences 2) As part of caching server URLs for developer mode 3) A generic native module that wraps NSUserDefaults NSPrivacyAccessedAPICategorySystemBootTime - 35F9.1: Best guess reason from RR API pulled in by boost Reviewed By: cipolleschi Differential Revision: D53682756 fbshipit-source-id: 0426fe0002a3bc8b45ef24053ac4228c9f61eb85 --------- Co-authored-by: Phillip Pan <[email protected]>
1 parent 35ee876 commit d669ff7

File tree

6 files changed

+142
-0
lines changed

6 files changed

+142
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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>NSPrivacyAccessedAPITypes</key>
6+
<array>
7+
<dict>
8+
<key>NSPrivacyAccessedAPIType</key>
9+
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
10+
<key>NSPrivacyAccessedAPITypeReasons</key>
11+
<array>
12+
<string>C617.1</string>
13+
</array>
14+
</dict>
15+
<dict>
16+
<key>NSPrivacyAccessedAPIType</key>
17+
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
18+
<key>NSPrivacyAccessedAPITypeReasons</key>
19+
<array>
20+
<string>CA92.1</string>
21+
</array>
22+
</dict>
23+
<dict>
24+
<key>NSPrivacyAccessedAPIType</key>
25+
<string>NSPrivacyAccessedAPICategorySystemBootTime</string>
26+
<key>NSPrivacyAccessedAPITypeReasons</key>
27+
<array>
28+
<string>35F9.1</string>
29+
</array>
30+
</dict>
31+
</array>
32+
<key>NSPrivacyCollectedDataTypes</key>
33+
<array/>
34+
<key>NSPrivacyTracking</key>
35+
<false/>
36+
</dict>
37+
</plist>

packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
E7DB216622B2F3EC005AC45F /* RCTRootViewIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E7DB216122B2F3EC005AC45F /* RCTRootViewIntegrationTests.m */; };
5959
E7DB216722B2F69F005AC45F /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E7DB213022B2C649005AC45F /* JavaScriptCore.framework */; };
6060
E7DB218C22B41FCD005AC45F /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E7DB218B22B41FCD005AC45F /* XCTest.framework */; };
61+
F0D621C32BBB9E38005960AC /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = F0D621C22BBB9E38005960AC /* PrivacyInfo.xcprivacy */; };
6162
/* End PBXBuildFile section */
6263

6364
/* Begin PBXContainerItemProxy section */
@@ -176,6 +177,7 @@
176177
E7DB216122B2F3EC005AC45F /* RCTRootViewIntegrationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTRootViewIntegrationTests.m; sourceTree = "<group>"; };
177178
E7DB218B22B41FCD005AC45F /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = XCTest.framework; sourceTree = DEVELOPER_DIR; };
178179
EDF27040BB5969AF2B1103C9 /* Pods-RNTesterIntegrationTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNTesterIntegrationTests.debug.xcconfig"; path = "Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests.debug.xcconfig"; sourceTree = "<group>"; };
180+
F0D621C22BBB9E38005960AC /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
179181
/* End PBXFileReference section */
180182

181183
/* Begin PBXFrameworksBuildPhase section */
@@ -223,6 +225,7 @@
223225
isa = PBXGroup;
224226
children = (
225227
0CC3BE1A25DDB68A0033CAEB /* RNTester.entitlements */,
228+
F0D621C22BBB9E38005960AC /* PrivacyInfo.xcprivacy */,
226229
E771AEEA22B44E3100EA1189 /* Info.plist */,
227230
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
228231
5C60EB1B226440DB0018C04F /* AppDelegate.mm */,
@@ -509,6 +512,7 @@
509512
files = (
510513
2DDEF0101F84BF7B00DBDF73 /* Images.xcassets in Resources */,
511514
8145AE06241172D900A3F8DA /* LaunchScreen.storyboard in Resources */,
515+
F0D621C32BBB9E38005960AC /* PrivacyInfo.xcprivacy in Resources */,
512516
3D2AFAF51D646CF80089D1A3 /* [email protected] in Resources */,
513517
);
514518
runOnlyForDeploymentPostprocessing = 0;
@@ -937,6 +941,17 @@
937941
GCC_WARN_UNUSED_FUNCTION = YES;
938942
GCC_WARN_UNUSED_LABEL = YES;
939943
GCC_WARN_UNUSED_VARIABLE = YES;
944+
HEADER_SEARCH_PATHS = (
945+
"$(inherited)",
946+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers",
947+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core",
948+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers/platform/ios",
949+
"${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx",
950+
"${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
951+
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
952+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
953+
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
954+
);
940955
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
941956
MTL_ENABLE_DEBUG_INFO = YES;
942957
ONLY_ACTIVE_ARCH = YES;
@@ -1019,6 +1034,17 @@
10191034
GCC_WARN_UNUSED_FUNCTION = YES;
10201035
GCC_WARN_UNUSED_LABEL = YES;
10211036
GCC_WARN_UNUSED_VARIABLE = YES;
1037+
HEADER_SEARCH_PATHS = (
1038+
"$(inherited)",
1039+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers",
1040+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core",
1041+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers/platform/ios",
1042+
"${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx",
1043+
"${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
1044+
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
1045+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
1046+
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
1047+
);
10221048
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
10231049
MTL_ENABLE_DEBUG_INFO = NO;
10241050
OTHER_CPLUSPLUSFLAGS = (

scripts/cocoapods/utils.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,44 @@ def self.apply_mac_catalyst_patches(installer)
144144
end
145145
end
146146

147+
def self.get_privacy_manifest_paths_from(user_project)
148+
privacy_manifests = user_project
149+
.files
150+
.select { |p|
151+
p.path&.end_with?('PrivacyInfo.xcprivacy')
152+
}
153+
return privacy_manifests
154+
end
155+
156+
def self.add_privacy_manifest_if_needed(installer)
157+
user_project = installer.aggregate_targets
158+
.map{ |t| t.user_project }
159+
.first
160+
privacy_manifest = self.get_privacy_manifest_paths_from(user_project).first
161+
if privacy_manifest.nil?
162+
file_timestamp_reason = {
163+
"NSPrivacyAccessedAPIType" => "NSPrivacyAccessedAPICategoryFileTimestamp",
164+
"NSPrivacyAccessedAPITypeReasons" => ["C617.1"],
165+
}
166+
user_defaults_reason = {
167+
"NSPrivacyAccessedAPIType" => "NSPrivacyAccessedAPICategoryUserDefaults",
168+
"NSPrivacyAccessedAPITypeReasons" => ["CA92.1"],
169+
}
170+
boot_time_reason = {
171+
"NSPrivacyAccessedAPIType" => "NSPrivacyAccessedAPICategorySystemBootTime",
172+
"NSPrivacyAccessedAPITypeReasons" => ["35F9.1"],
173+
}
174+
privacy_manifest = {
175+
"NSPrivacyCollectedDataTypes" => [],
176+
"NSPrivacyTracking" => false,
177+
"NSPrivacyAccessedAPITypes" => [file_timestamp_reason, user_defaults_reason, boot_time_reason]
178+
}
179+
path = File.join(user_project.path.parent, "PrivacyInfo.xcprivacy")
180+
Xcodeproj::Plist.write_to_path(privacy_manifest, path)
181+
Pod::UI.puts "Your app does not have a privacy manifest! A template has been generated containing Required Reasons API usage in the core React Native library. Please add the PrivacyInfo.xcprivacy file to your project and complete data use, tracking and any additional required reasons your app is using according to Apple's guidance: https://developer.apple.com/documentation/bundleresources/privacy_manifest_files. Then, you will need to manually add this file to your project in Xcode.".red
182+
end
183+
end
184+
147185
def self.fix_flipper_for_xcode_15_3(installer)
148186
installer.pods_project.targets.each do |target|
149187
if target.name == 'Flipper'

scripts/react_native_pods.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ def react_native_post_install(installer, react_native_path = "../node_modules/re
227227
ReactNativePodsUtils.apply_xcode_15_patch(installer)
228228
ReactNativePodsUtils.updateIphoneOSDeploymentTarget(installer)
229229
ReactNativePodsUtils.fix_flipper_for_xcode_15_3(installer)
230+
ReactNativePodsUtils.add_privacy_manifest_if_needed(installer)
230231

231232
NewArchitectureHelper.set_clang_cxx_language_standard_if_needed(installer)
232233
is_new_arch_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == "1"

template/ios/HelloWorld.xcodeproj/project.pbxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
5DCACB8F33CDC322A6C60F78 /* libPods-HelloWorld.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-HelloWorld.a"; sourceTree = BUILT_PRODUCTS_DIR; };
4444
81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = LaunchScreen.storyboard; path = HelloWorld/LaunchScreen.storyboard; sourceTree = "<group>"; };
4545
89C6BE57DB24E9ADA2F236DE /* Pods-HelloWorld-HelloWorldTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HelloWorld-HelloWorldTests.release.xcconfig"; path = "Target Support Files/Pods-HelloWorld-HelloWorldTests/Pods-HelloWorld-HelloWorldTests.release.xcconfig"; sourceTree = "<group>"; };
46+
CD42C8902BDBCB100036610F /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = PrivacyInfo.xcprivacy; path = HelloWorld/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
4647
ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
4748
/* End PBXFileReference section */
4849

@@ -86,6 +87,7 @@
8687
13B07FAE1A68108700A75B9A /* HelloWorld */ = {
8788
isa = PBXGroup;
8889
children = (
90+
CD42C8902BDBCB100036610F /* PrivacyInfo.xcprivacy */,
8991
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
9092
13B07FB01A68108700A75B9A /* AppDelegate.mm */,
9193
13B07FB51A68108700A75B9A /* Images.xcassets */,
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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>NSPrivacyCollectedDataTypes</key>
6+
<array>
7+
</array>
8+
<key>NSPrivacyAccessedAPITypes</key>
9+
<array>
10+
<dict>
11+
<key>NSPrivacyAccessedAPIType</key>
12+
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
13+
<key>NSPrivacyAccessedAPITypeReasons</key>
14+
<array>
15+
<string>C617.1</string>
16+
</array>
17+
</dict>
18+
<dict>
19+
<key>NSPrivacyAccessedAPIType</key>
20+
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
21+
<key>NSPrivacyAccessedAPITypeReasons</key>
22+
<array>
23+
<string>CA92.1</string>
24+
</array>
25+
</dict>
26+
<dict>
27+
<key>NSPrivacyAccessedAPIType</key>
28+
<string>NSPrivacyAccessedAPICategorySystemBootTime</string>
29+
<key>NSPrivacyAccessedAPITypeReasons</key>
30+
<array>
31+
<string>35F9.1</string>
32+
</array>
33+
</dict>
34+
</array>
35+
<key>NSPrivacyTracking</key>
36+
<false/>
37+
</dict>
38+
</plist>

0 commit comments

Comments
 (0)