Skip to content

Commit 92c6d22

Browse files
philIiphuntie
authored andcommitted
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 # Conflicts: # packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj
1 parent bb5451b commit 92c6d22

4 files changed

Lines changed: 84 additions & 4 deletions

File tree

packages/react-native/scripts/cocoapods/utils.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,44 @@ def self.set_imagemanager_search_path(target_installation_result)
576576
ReactNativePodsUtils.update_header_paths_if_depends_on(target_installation_result, "React-ImageManager", header_search_paths)
577577
end
578578

579+
def self.get_privacy_manifest_paths_from(user_project)
580+
privacy_manifests = user_project
581+
.files
582+
.select { |p|
583+
p.path&.end_with?('PrivacyInfo.xcprivacy')
584+
}
585+
return privacy_manifests
586+
end
587+
588+
def self.add_privacy_manifest_if_needed(installer)
589+
user_project = installer.aggregate_targets
590+
.map{ |t| t.user_project }
591+
.first
592+
privacy_manifest = self.get_privacy_manifest_paths_from(user_project).first
593+
if privacy_manifest.nil?
594+
file_timestamp_reason = {
595+
"NSPrivacyAccessedAPIType" => "NSPrivacyAccessedAPICategoryFileTimestamp",
596+
"NSPrivacyAccessedAPITypeReasons" => ["C617.1"],
597+
}
598+
user_defaults_reason = {
599+
"NSPrivacyAccessedAPIType" => "NSPrivacyAccessedAPICategoryUserDefaults",
600+
"NSPrivacyAccessedAPITypeReasons" => ["CA92.1"],
601+
}
602+
boot_time_reason = {
603+
"NSPrivacyAccessedAPIType" => "NSPrivacyAccessedAPICategorySystemBootTime",
604+
"NSPrivacyAccessedAPITypeReasons" => ["35F9.1"],
605+
}
606+
privacy_manifest = {
607+
"NSPrivacyCollectedDataTypes" => [],
608+
"NSPrivacyTracking" => false,
609+
"NSPrivacyAccessedAPITypes" => [file_timestamp_reason, user_defaults_reason, boot_time_reason]
610+
}
611+
path = File.join(user_project.path.parent, "PrivacyInfo.xcprivacy")
612+
Xcodeproj::Plist.write_to_path(privacy_manifest, path)
613+
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/.../privacy_manifest_files. Then, you will need to manually add this file to your project in Xcode.".red
614+
end
615+
end
616+
579617
def self.react_native_pods
580618
return [
581619
"DoubleConversion",

packages/react-native/scripts/react_native_pods.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ def react_native_post_install(
292292
ReactNativePodsUtils.updateOSDeploymentTarget(installer)
293293
ReactNativePodsUtils.set_dynamic_frameworks_flags(installer)
294294
ReactNativePodsUtils.add_ndebug_flag_to_pods_in_release(installer)
295+
ReactNativePodsUtils.add_privacy_manifest_if_needed(installer)
295296

296297
NewArchitectureHelper.set_clang_cxx_language_standard_if_needed(installer)
297298
NewArchitectureHelper.modify_flags_for_new_architecture(installer, NewArchitectureHelper.new_arch_enabled)
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: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
E7DB216422B2F3EC005AC45F /* RCTUIManagerScenarioTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E7DB215F22B2F3EC005AC45F /* RCTUIManagerScenarioTests.m */; };
5757
E7DB216722B2F69F005AC45F /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E7DB213022B2C649005AC45F /* JavaScriptCore.framework */; };
5858
E7DB218C22B41FCD005AC45F /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E7DB218B22B41FCD005AC45F /* XCTest.framework */; };
59+
F0D621C32BBB9E38005960AC /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = F0D621C22BBB9E38005960AC /* PrivacyInfo.xcprivacy */; };
5960
/* End PBXBuildFile section */
6061

6162
/* Begin PBXContainerItemProxy section */
@@ -162,6 +163,7 @@
162163
E7DB218B22B41FCD005AC45F /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = XCTest.framework; sourceTree = DEVELOPER_DIR; };
163164
EB39930F368F8A8EF2223131 /* Pods-RNTesterIntegrationTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNTesterIntegrationTests.release.xcconfig"; path = "Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests.release.xcconfig"; sourceTree = "<group>"; };
164165
FDC71B375B04D2F3DD483B6C /* libPods-RNTester.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNTester.a"; sourceTree = BUILT_PRODUCTS_DIR; };
166+
F0D621C22BBB9E38005960AC /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
165167
/* End PBXFileReference section */
166168

167169
/* Begin PBXFrameworksBuildPhase section */
@@ -207,6 +209,7 @@
207209
13B07FAE1A68108700A75B9A /* RNTester */ = {
208210
isa = PBXGroup;
209211
children = (
212+
F0D621C22BBB9E38005960AC /* PrivacyInfo.xcprivacy */,
210213
AC474BFB29BBD4A1002BDAED /* RNTester.xctestplan */,
211214
E771AEEA22B44E3100EA1189 /* Info.plist */,
212215
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
@@ -477,6 +480,7 @@
477480
files = (
478481
2DDEF0101F84BF7B00DBDF73 /* Images.xcassets in Resources */,
479482
8145AE06241172D900A3F8DA /* LaunchScreen.storyboard in Resources */,
483+
F0D621C32BBB9E38005960AC /* PrivacyInfo.xcprivacy in Resources */,
480484
3D2AFAF51D646CF80089D1A3 /* legacy_image@2x.png in Resources */,
481485
);
482486
runOnlyForDeploymentPostprocessing = 0;
@@ -927,8 +931,8 @@
927931
"${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx",
928932
"${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
929933
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
930-
" ${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
931-
" ${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
934+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
935+
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
932936
);
933937
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
934938
LD = "$(REACT_NATIVE_PATH)/scripts/xcode/ccache-clang.sh";
@@ -1024,8 +1028,8 @@
10241028
"${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx",
10251029
"${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
10261030
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
1027-
" ${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
1028-
" ${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
1031+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
1032+
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
10291033
);
10301034
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
10311035
LD = "$(REACT_NATIVE_PATH)/scripts/xcode/ccache-clang.sh";

0 commit comments

Comments
 (0)