Skip to content

Commit 7b803b2

Browse files
philIipcipolleschi
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 631c013 commit 7b803b2

File tree

4 files changed

+103
-0
lines changed

4 files changed

+103
-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: 27 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,8 @@
223225
isa = PBXGroup;
224226
children = (
225227
0CC3BE1A25DDB68A0033CAEB /* RNTester.entitlements */,
228+
F0D621C22BBB9E38005960AC /* PrivacyInfo.xcprivacy */,
229+
AC474BFB29BBD4A1002BDAED /* RNTester.xctestplan */,
226230
E771AEEA22B44E3100EA1189 /* Info.plist */,
227231
13B07FAF1A68108700A75B9A /* AppDelegate.h */,
228232
5C60EB1B226440DB0018C04F /* AppDelegate.mm */,
@@ -509,6 +513,7 @@
509513
files = (
510514
2DDEF0101F84BF7B00DBDF73 /* Images.xcassets in Resources */,
511515
8145AE06241172D900A3F8DA /* LaunchScreen.storyboard in Resources */,
516+
F0D621C32BBB9E38005960AC /* PrivacyInfo.xcprivacy in Resources */,
512517
3D2AFAF51D646CF80089D1A3 /* [email protected] in Resources */,
513518
);
514519
runOnlyForDeploymentPostprocessing = 0;
@@ -937,6 +942,17 @@
937942
GCC_WARN_UNUSED_FUNCTION = YES;
938943
GCC_WARN_UNUSED_LABEL = YES;
939944
GCC_WARN_UNUSED_VARIABLE = YES;
945+
HEADER_SEARCH_PATHS = (
946+
"$(inherited)",
947+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers",
948+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core",
949+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers/platform/ios",
950+
"${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx",
951+
"${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
952+
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
953+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
954+
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
955+
);
940956
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
941957
MTL_ENABLE_DEBUG_INFO = YES;
942958
ONLY_ACTIVE_ARCH = YES;
@@ -1019,6 +1035,17 @@
10191035
GCC_WARN_UNUSED_FUNCTION = YES;
10201036
GCC_WARN_UNUSED_LABEL = YES;
10211037
GCC_WARN_UNUSED_VARIABLE = YES;
1038+
HEADER_SEARCH_PATHS = (
1039+
"$(inherited)",
1040+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers",
1041+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core",
1042+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon-Samples/ReactCommon_Samples.framework/Headers/platform/ios",
1043+
"${PODS_CONFIGURATION_BUILD_DIR}/React-Fabric/React_Fabric.framework/Headers/react/renderer/components/view/platform/cxx",
1044+
"${PODS_CONFIGURATION_BUILD_DIR}/React-NativeModulesApple/React_NativeModulesApple.framework/Headers",
1045+
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios",
1046+
"${PODS_CONFIGURATION_BUILD_DIR}/ReactCommon/ReactCommon.framework/Headers",
1047+
"${PODS_CONFIGURATION_BUILD_DIR}/React-graphics/React_graphics.framework/Headers",
1048+
);
10221049
IPHONEOS_DEPLOYMENT_TARGET = 12.4;
10231050
MTL_ENABLE_DEBUG_INFO = NO;
10241051
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"

0 commit comments

Comments
 (0)