Skip to content

Commit

Permalink
add privacy manifest to pod install
Browse files Browse the repository at this point in the history
Summary:
Changelog: [iOS][Added]

this creates the RN privacy manifest in the ios build step if user has not created one yet.

Reviewed By: cipolleschi

Differential Revision: D53687232
  • Loading branch information
philIip authored and facebook-github-bot committed Feb 14, 2024
1 parent b8c2020 commit 3e3c6af
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
31 changes: 31 additions & 0 deletions packages/react-native/scripts/cocoapods/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion packages/react-native/scripts/react_native_pods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 26 additions & 0 deletions packages/rn-tester/PrivacyInfo.xcprivacy
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>C617.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>CA56D.1</string>
<string>CA92.1</string>
</array>
</dict>
</array>
</dict>
</plist>

0 comments on commit 3e3c6af

Please sign in to comment.