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