react-native-community / template

The React Native Community Template - getting started building RN apps for Android & iOS
MIT License
70 stars 16 forks source link

fix: Add privacyInfo reference for new projects to prevent PrivacyInfo being added twice #53

Closed okwasniewski closed 2 months ago

okwasniewski commented 2 months ago

Summary:

This PR fixes an issue with PrivacyInfo files.

When generating a new project for using the latest RC 0.76.0.rc0 I got two privacy manifests references in Xcode.

This is because PrivacyManifestUtils look for build phase reference:

reference_exists = target.resources_build_phase.files_references.any? { |file_ref| file_ref&.path&.end_with? "xcprivacy" }

Which doesn't exist for the generated template.

Here is how Xcode file tree looks like after installing pods:

CleanShot 2024-09-12 at 13 23 21@2x

We can also fix this inside of PrivacyManifestUtils utility but Im not sure which one is better.

When you create this file in Xcode its added to the PBXBuildFile section so the utility works good for existing projects, this issue only appears in newly generated projects.

Changelog:

[IOS] [FIXED] - Don't add PrivacyInfo to Xcode references twice

Test Plan:

  1. Generate a new project
  2. Execute pod install
  3. Check if only one PrivacyInfo file exists
okwasniewski commented 2 months ago

Let me know if you prefer this to be handled in PrivacyManifestUtils inside of Core

okwasniewski commented 2 months ago

cc: @cipolleschi

cipolleschi commented 2 months ago

Yeah, it would be better to fix it in Core. Otherwise this change will popup to every project that wants to migrate, while if we do it in core, the first time that users do pod install we will be able to fix the project for them.

okwasniewski commented 2 months ago

Linking to the PR for visibility: https://github.com/facebook/react-native/pull/46457