Skip to content

Commit d39712f

Browse files
philIipfacebook-github-bot
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
1 parent 520d120 commit d39712f

File tree

4 files changed

+84
-4
lines changed

4 files changed

+84
-4
lines changed

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

+38
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

+1
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ def react_native_post_install(
296296
ReactNativePodsUtils.updateOSDeploymentTarget(installer)
297297
ReactNativePodsUtils.set_dynamic_frameworks_flags(installer)
298298
ReactNativePodsUtils.add_ndebug_flag_to_pods_in_release(installer)
299+
ReactNativePodsUtils.add_privacy_manifest_if_needed(installer)
299300

300301
NewArchitectureHelper.set_clang_cxx_language_standard_if_needed(installer)
301302
NewArchitectureHelper.modify_flags_for_new_architecture(installer, NewArchitectureHelper.new_arch_enabled)
+37
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

+8-4
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
E7DB215E22B2F3EC005AC45F /* RCTLoggingTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTLoggingTests.m; sourceTree = "<group>"; };
163164
E7DB215F22B2F3EC005AC45F /* RCTUIManagerScenarioTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTUIManagerScenarioTests.m; sourceTree = "<group>"; };
164165
E7DB218B22B41FCD005AC45F /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = XCTest.framework; sourceTree = DEVELOPER_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 /* [email protected] in Resources */,
481485
);
482486
runOnlyForDeploymentPostprocessing = 0;
@@ -925,8 +929,8 @@
925929
"${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx",
926930
"${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
927931
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
928-
" ${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
929-
" ${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
932+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
933+
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
930934
);
931935
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
932936
MTL_ENABLE_DEBUG_INFO = YES;
@@ -1018,8 +1022,8 @@
10181022
"${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx",
10191023
"${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
10201024
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
1021-
" ${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
1022-
" ${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
1025+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
1026+
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
10231027
);
10241028
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
10251029
MTL_ENABLE_DEBUG_INFO = NO;

0 commit comments

Comments
 (0)