Skip to content

Commit 3ccbd9c

Browse files
philIipalfonsocj
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 2bcf188 commit 3ccbd9c

4 files changed

Lines changed: 104 additions & 0 deletions

File tree

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

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

563+
def self.get_privacy_manifest_paths_from(user_project)
564+
privacy_manifests = user_project
565+
.files
566+
.select { |p|
567+
p.path&.end_with?('PrivacyInfo.xcprivacy')
568+
}
569+
return privacy_manifests
570+
end
571+
572+
def self.add_privacy_manifest_if_needed(installer)
573+
user_project = installer.aggregate_targets
574+
.map{ |t| t.user_project }
575+
.first
576+
privacy_manifest = self.get_privacy_manifest_paths_from(user_project).first
577+
if privacy_manifest.nil?
578+
file_timestamp_reason = {
579+
"NSPrivacyAccessedAPIType" => "NSPrivacyAccessedAPICategoryFileTimestamp",
580+
"NSPrivacyAccessedAPITypeReasons" => ["C617.1"],
581+
}
582+
user_defaults_reason = {
583+
"NSPrivacyAccessedAPIType" => "NSPrivacyAccessedAPICategoryUserDefaults",
584+
"NSPrivacyAccessedAPITypeReasons" => ["CA92.1"],
585+
}
586+
boot_time_reason = {
587+
"NSPrivacyAccessedAPIType" => "NSPrivacyAccessedAPICategorySystemBootTime",
588+
"NSPrivacyAccessedAPITypeReasons" => ["35F9.1"],
589+
}
590+
privacy_manifest = {
591+
"NSPrivacyCollectedDataTypes" => [],
592+
"NSPrivacyTracking" => false,
593+
"NSPrivacyAccessedAPITypes" => [file_timestamp_reason, user_defaults_reason, boot_time_reason]
594+
}
595+
path = File.join(user_project.path.parent, "PrivacyInfo.xcprivacy")
596+
Xcodeproj::Plist.write_to_path(privacy_manifest, path)
597+
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
598+
end
599+
end
600+
563601
def self.react_native_pods
564602
return [
565603
"DoubleConversion",

packages/react-native/scripts/react_native_pods.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,9 @@ def react_native_post_install(
309309
ReactNativePodsUtils.apply_xcode_15_patch(installer)
310310
ReactNativePodsUtils.updateOSDeploymentTarget(installer)
311311
ReactNativePodsUtils.fix_flipper_for_xcode_15_3(installer)
312+
ReactNativePodsUtils.set_dynamic_frameworks_flags(installer)
313+
ReactNativePodsUtils.add_ndebug_flag_to_pods_in_release(installer)
314+
ReactNativePodsUtils.add_privacy_manifest_if_needed(installer)
312315

313316
NewArchitectureHelper.set_clang_cxx_language_standard_if_needed(installer)
314317
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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
E7DB216522B2F3EC005AC45F /* RNTesterSnapshotTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E7DB216022B2F3EC005AC45F /* RNTesterSnapshotTests.m */; };
5858
E7DB216722B2F69F005AC45F /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E7DB213022B2C649005AC45F /* JavaScriptCore.framework */; };
5959
E7DB218C22B41FCD005AC45F /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E7DB218B22B41FCD005AC45F /* XCTest.framework */; };
60+
F0D621C32BBB9E38005960AC /* PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = F0D621C22BBB9E38005960AC /* PrivacyInfo.xcprivacy */; };
6061
/* End PBXBuildFile section */
6162

6263
/* Begin PBXContainerItemProxy section */
@@ -165,6 +166,7 @@
165166
E7DB215F22B2F3EC005AC45F /* RCTUIManagerScenarioTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTUIManagerScenarioTests.m; sourceTree = "<group>"; };
166167
E7DB216022B2F3EC005AC45F /* RNTesterSnapshotTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNTesterSnapshotTests.m; sourceTree = "<group>"; };
167168
E7DB218B22B41FCD005AC45F /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = XCTest.framework; sourceTree = DEVELOPER_DIR; };
169+
F0D621C22BBB9E38005960AC /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
168170
/* End PBXFileReference section */
169171

170172
/* Begin PBXFrameworksBuildPhase section */
@@ -211,6 +213,7 @@
211213
isa = PBXGroup;
212214
children = (
213215
0CC3BE1A25DDB68A0033CAEB /* RNTester.entitlements */,
216+
F0D621C22BBB9E38005960AC /* PrivacyInfo.xcprivacy */,
214217
AC474BFB29BBD4A1002BDAED /* RNTester.xctestplan */,
215218
E771AEEA22B44E3100EA1189 /* Info.plist */,
216219
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
@@ -482,6 +485,7 @@
482485
files = (
483486
2DDEF0101F84BF7B00DBDF73 /* Images.xcassets in Resources */,
484487
8145AE06241172D900A3F8DA /* LaunchScreen.storyboard in Resources */,
488+
F0D621C32BBB9E38005960AC /* PrivacyInfo.xcprivacy in Resources */,
485489
3D2AFAF51D646CF80089D1A3 /* legacy_image@2x.png in Resources */,
486490
);
487491
runOnlyForDeploymentPostprocessing = 0;
@@ -925,6 +929,17 @@
925929
GCC_WARN_UNUSED_FUNCTION = YES;
926930
GCC_WARN_UNUSED_LABEL = YES;
927931
GCC_WARN_UNUSED_VARIABLE = YES;
932+
HEADER_SEARCH_PATHS = (
933+
"$(inherited)",
934+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers",
935+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core",
936+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers/platform/ios",
937+
"${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx",
938+
"${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
939+
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
940+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
941+
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
942+
);
928943
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
929944
MTL_ENABLE_DEBUG_INFO = YES;
930945
ONLY_ACTIVE_ARCH = YES;
@@ -1010,6 +1025,17 @@
10101025
GCC_WARN_UNUSED_FUNCTION = YES;
10111026
GCC_WARN_UNUSED_LABEL = YES;
10121027
GCC_WARN_UNUSED_VARIABLE = YES;
1028+
HEADER_SEARCH_PATHS = (
1029+
"$(inherited)",
1030+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers",
1031+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core",
1032+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers/platform/ios",
1033+
"${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx",
1034+
"${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
1035+
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
1036+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
1037+
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
1038+
);
10131039
IPHONEOS_DEPLOYMENT_TARGET = 13.4;
10141040
MTL_ENABLE_DEBUG_INFO = NO;
10151041
OTHER_CFLAGS = (

0 commit comments

Comments
 (0)