From 2f4b9e8e86c47c3b020a722bb47ebeff92b00d98 Mon Sep 17 00:00:00 2001 From: Phillip Pan Date: Tue, 13 Feb 2024 22:17:33 -0800 Subject: [PATCH 1/2] 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 access the filesize in order to handle loading JavaScript. [RCTJavaScriptLoader](https://github.com/facebook/react-native/blob/3b2c4a18348892acf14120bc42fa1f54c261e914/packages/react-native/React/Base/RCTJavaScriptLoader.mm#L190), [JSBigString](https://github.com/facebook/react-native/blob/3b2c4a18348892acf14120bc42fa1f54c261e914/packages/react-native/ReactCommon/cxxreact/JSBigString.cpp#L102), [jsilib-posix](https://github.com/facebook/react-native/blob/3b2c4a18348892acf14120bc42fa1f54c261e914/packages/react-native/ReactCommon/jsi/jsi/jsilib-posix.cpp#L62) NSPrivacyAccessedAPICategoryUserDefaults - CA56D.1: - We have one native module that is a wrapper of NSUserDefaults to give access in JavaScript product code. [RCTSettingsManager](https://github.com/facebook/react-native/blob/3b2c4a18348892acf14120bc42fa1f54c261e914/packages/react-native/Libraries/Settings/RCTSettingsManager.mm#L8) - We have a utility file that let's users support RTL in their app. [RCTi18nUtil](https://github.com/facebook/react-native/blob/3b2c4a18348892acf14120bc42fa1f54c261e914/packages/react-native/React/Modules/RCTI18nUtil.m#L8) - CA92.1: Within our framework, we use NSUserDefaults for a few things: 1) To store developer preferences. [RCTDevSettings](https://github.com/facebook/react-native/blob/3b2c4a18348892acf14120bc42fa1f54c261e914/packages/react-native/React/CoreModules/RCTDevSettings.mm#L8) 2) To store information about the JavaScript product code bundle. [RCTBundleURLProvider](https://github.com/facebook/react-native/blob/3b2c4a18348892acf14120bc42fa1f54c261e914/packages/react-native/React/Base/RCTBundleURLProvider.mm#L125) Differential Revision: D53682756 --- .../ios/HelloWorld.xcodeproj/project.pbxproj | 2 ++ .../ios/HelloWorld/PrivacyInfo.xcprivacy | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 packages/react-native/template/ios/HelloWorld/PrivacyInfo.xcprivacy diff --git a/packages/react-native/template/ios/HelloWorld.xcodeproj/project.pbxproj b/packages/react-native/template/ios/HelloWorld.xcodeproj/project.pbxproj index d059f8e4f5fb7c..40b32ffd09ec6c 100644 --- a/packages/react-native/template/ios/HelloWorld.xcodeproj/project.pbxproj +++ b/packages/react-native/template/ios/HelloWorld.xcodeproj/project.pbxproj @@ -36,6 +36,7 @@ 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = HelloWorld/Images.xcassets; sourceTree = ""; }; 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = HelloWorld/Info.plist; sourceTree = ""; }; 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = HelloWorld/main.m; sourceTree = ""; }; + 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = PrivacyInfo.xcprivacy; path = HelloWorld/PrivacyInfo.xcprivacy; sourceTree = ""; }; 19F6CBCC0A4E27FBF8BF4A61 /* libPods-HelloWorld-HelloWorldTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-HelloWorld-HelloWorldTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 3B4392A12AC88292D35C810B /* Pods-HelloWorld.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HelloWorld.debug.xcconfig"; path = "Target Support Files/Pods-HelloWorld/Pods-HelloWorld.debug.xcconfig"; sourceTree = ""; }; 5709B34CF0A7D63546082F79 /* Pods-HelloWorld.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-HelloWorld.release.xcconfig"; path = "Target Support Files/Pods-HelloWorld/Pods-HelloWorld.release.xcconfig"; sourceTree = ""; }; @@ -92,6 +93,7 @@ 13B07FB61A68108700A75B9A /* Info.plist */, 81AB9BB72411601600AC10FF /* LaunchScreen.storyboard */, 13B07FB71A68108700A75B9A /* main.m */, + 13B07FB81A68108700A75B9A /* PrivacyInfo.xcprivacy */, ); name = HelloWorld; sourceTree = ""; diff --git a/packages/react-native/template/ios/HelloWorld/PrivacyInfo.xcprivacy b/packages/react-native/template/ios/HelloWorld/PrivacyInfo.xcprivacy new file mode 100644 index 00000000000000..527188f26ca2b4 --- /dev/null +++ b/packages/react-native/template/ios/HelloWorld/PrivacyInfo.xcprivacy @@ -0,0 +1,26 @@ + + + + + NSPrivacyAccessedAPITypes + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryFileTimestamp + NSPrivacyAccessedAPITypeReasons + + C617.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryUserDefaults + NSPrivacyAccessedAPITypeReasons + + CA56D.1 + CA92.1 + + + + + From 393e7d63a97884986dbb43992374879f9cb9ba4e Mon Sep 17 00:00:00 2001 From: Phillip Pan Date: Tue, 13 Feb 2024 22:17:33 -0800 Subject: [PATCH 2/2] 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 access the filesize in order to handle loading JavaScript. [RCTJavaScriptLoader](https://github.com/facebook/react-native/blob/3b2c4a18348892acf14120bc42fa1f54c261e914/packages/react-native/React/Base/RCTJavaScriptLoader.mm#L190), [JSBigString](https://github.com/facebook/react-native/blob/3b2c4a18348892acf14120bc42fa1f54c261e914/packages/react-native/ReactCommon/cxxreact/JSBigString.cpp#L102), [jsilib-posix](https://github.com/facebook/react-native/blob/3b2c4a18348892acf14120bc42fa1f54c261e914/packages/react-native/ReactCommon/jsi/jsi/jsilib-posix.cpp#L62) NSPrivacyAccessedAPICategoryUserDefaults - CA56D.1: - We have one native module that is a wrapper of NSUserDefaults to give access in JavaScript product code. [RCTSettingsManager](https://github.com/facebook/react-native/blob/3b2c4a18348892acf14120bc42fa1f54c261e914/packages/react-native/Libraries/Settings/RCTSettingsManager.mm#L8) - We have a utility file that let's users support RTL in their app. [RCTi18nUtil](https://github.com/facebook/react-native/blob/3b2c4a18348892acf14120bc42fa1f54c261e914/packages/react-native/React/Modules/RCTI18nUtil.m#L8) - CA92.1: Within our framework, we use NSUserDefaults for a few things: 1) To store developer preferences. [RCTDevSettings](https://github.com/facebook/react-native/blob/3b2c4a18348892acf14120bc42fa1f54c261e914/packages/react-native/React/CoreModules/RCTDevSettings.mm#L8) 2) To store information about the JavaScript product code bundle. [RCTBundleURLProvider](https://github.com/facebook/react-native/blob/3b2c4a18348892acf14120bc42fa1f54c261e914/packages/react-native/React/Base/RCTBundleURLProvider.mm#L125) Reviewed By: cipolleschi Differential Revision: D53687232 --- .../react-native/scripts/cocoapods/utils.rb | 31 +++++++++++++++++++ .../react-native/scripts/react_native_pods.rb | 3 +- packages/rn-tester/PrivacyInfo.xcprivacy | 26 ++++++++++++++++ 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 packages/rn-tester/PrivacyInfo.xcprivacy diff --git a/packages/react-native/scripts/cocoapods/utils.rb b/packages/react-native/scripts/cocoapods/utils.rb index 6df005cee4fc1e..59adebde88dce1 100644 --- a/packages/react-native/scripts/cocoapods/utils.rb +++ b/packages/react-native/scripts/cocoapods/utils.rb @@ -556,6 +556,37 @@ def self.set_imagemanager_search_path(target_installation_result) ReactNativePodsUtils.update_header_paths_if_depends_on(target_installation_result, "React-ImageManager", header_search_paths) end + def self.get_privacy_manifest_paths_from(user_project) + privacy_manifests = user_project + .files + .select { |p| + p.name&.end_with?('PrivacyInfo.xcprivacy') + } + return privacy_manifests + end + + def self.add_privacy_manifest_if_needed(installer) + user_project = installer.aggregate_targets + .map{ |t| t.user_project } + .first + privacy_manifest = self.get_privacy_manifest_paths_from(user_project).first + if privacy_manifest.nil? + file_timestamp_reason = { + "NSPrivacyAccessedAPIType" => "NSPrivacyAccessedAPICategoryFileTimestamp", + "NSPrivacyAccessedAPITypeReasons" => ["C617.1"], + } + user_defaults_reason = { + "NSPrivacyAccessedAPIType" => "NSPrivacyAccessedAPICategoryUserDefaults", + "NSPrivacyAccessedAPITypeReasons" => ["CA56D.1", "CA92.1"], + } + privacy_manifest = { + "NSPrivacyAccessedAPITypes" => [file_timestamp_reason, user_defaults_reason] + } + path = File.join(user_project.path.parent, "PrivacyInfo.xcprivacy") + Xcodeproj::Plist.write_to_path(privacy_manifest, path) + end + end + def self.react_native_pods return [ "DoubleConversion", diff --git a/packages/react-native/scripts/react_native_pods.rb b/packages/react-native/scripts/react_native_pods.rb index 0943e9029e9dc5..c47fb46665d1b1 100644 --- a/packages/react-native/scripts/react_native_pods.rb +++ b/packages/react-native/scripts/react_native_pods.rb @@ -286,10 +286,11 @@ def react_native_post_install( ReactNativePodsUtils.set_use_hermes_build_setting(installer, hermes_enabled) ReactNativePodsUtils.set_node_modules_user_settings(installer, react_native_path) ReactNativePodsUtils.set_ccache_compiler_and_linker_build_settings(installer, react_native_path, ccache_enabled) - ReactNativePodsUtils.apply_xcode_15_patch(installer) + ReactNativePodsUtils.apply_xcode_15_patch(installer) ReactNativePodsUtils.updateOSDeploymentTarget(installer) ReactNativePodsUtils.set_dynamic_frameworks_flags(installer) ReactNativePodsUtils.add_ndebug_flag_to_pods_in_release(installer) + ReactNativePodsUtils.add_privacy_manifest_if_needed(installer) NewArchitectureHelper.set_clang_cxx_language_standard_if_needed(installer) NewArchitectureHelper.modify_flags_for_new_architecture(installer, NewArchitectureHelper.new_arch_enabled) diff --git a/packages/rn-tester/PrivacyInfo.xcprivacy b/packages/rn-tester/PrivacyInfo.xcprivacy new file mode 100644 index 00000000000000..527188f26ca2b4 --- /dev/null +++ b/packages/rn-tester/PrivacyInfo.xcprivacy @@ -0,0 +1,26 @@ + + + + + NSPrivacyAccessedAPITypes + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryFileTimestamp + NSPrivacyAccessedAPITypeReasons + + C617.1 + + + + NSPrivacyAccessedAPIType + NSPrivacyAccessedAPICategoryUserDefaults + NSPrivacyAccessedAPITypeReasons + + CA56D.1 + CA92.1 + + + + +