Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Priavacy Policy aggregation errors on get_privacyinfo_file_path #44437

Open
lorenc-tomasz opened this issue May 7, 2024 · 10 comments
Open

Priavacy Policy aggregation errors on get_privacyinfo_file_path #44437

lorenc-tomasz opened this issue May 7, 2024 · 10 comments
Labels
Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project.

Comments

@lorenc-tomasz
Copy link

lorenc-tomasz commented May 7, 2024

Description

When upgraded from RN 0.73.8 to RN 0.74.1 pod install gives error on get_privacyinfo_file_path

Steps to reproduce

Update from RN 0.73.8 with PrivacyManifest to RN 0.74.1

React Native Version

0.74.1

Affected Platforms

Runtime - iOS

Output of npx react-native info

System:
  OS: macOS 14.4.1
  CPU: (12) arm64 Apple M2 Pro
  Memory: 114.86 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 21.7.3
    path: /opt/homebrew/bin/node
  Yarn:
    version: 1.22.22
    path: ~/Desktop/Projects/Interparking/Interparking.MobileChannel.App/node_modules/.bin/yarn
  npm:
    version: 10.5.0
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2024.04.15.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.15.2
    path: /Users/tomaszlorenc/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.4
      - iOS 17.4
      - macOS 14.4
      - tvOS 17.4
      - visionOS 1.1
      - watchOS 10.4
  Android SDK:
    API Levels:
      - "28"
      - "29"
      - "30"
      - "31"
      - "32"
      - "33"
      - "33"
      - "33"
      - "34"
    Build Tools:
      - 30.0.3
      - 33.0.0
      - 33.0.1
      - 33.0.2
      - 34.0.0
    System Images:
      - android-26 | Google APIs ARM 64 v8a
      - android-28 | Google ARM64-V8a Play ARM 64 v8a
      - android-29 | Google Play ARM 64 v8a
      - android-31 | Google APIs ARM 64 v8a
      - android-33-ext4 | Google Play ARM 64 v8a
      - android-33-ext5 | Google Play ARM 64 v8a
      - android-33 | Google APIs ARM 64 v8a
      - android-34 | Google APIs ARM 64 v8a
      - android-34 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2023.3 AI-233.14808.21.2331.11709847
  Xcode:
    version: 15.3/15E204a
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.11
    path: /usr/bin/javac
  Ruby:
    version: 2.7.6
    path: /Users/tomaszlorenc/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.3.1
    wanted: 18.3.1
  react-native:
    installed: 0.74.1
    wanted: 0.74.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: false

Stacktrace or Logs

[!] An error occurred while processing the post-install hook of the Podfile.

undefined method `end_with?' for nil:NilClass

/Users/username/Desktop/Projects/nameA/App/node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb:85:in `block in get_privacyinfo_file_path'
/Users/username/Desktop/Projects/nameA/App/node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb:85:in `each'
/Users/username/Desktop/Projects/nameA/App/node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb:85:in `find'
/Users/username/Desktop/Projects/nameA/App/node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb:85:in `get_privacyinfo_file_path'
/Users/username/Desktop/Projects/nameA/App/node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb:10:in `add_aggregated_privacy_manifest'
/Users/username/Desktop/Projects/nameA/App/node_modules/react-native/scripts/react_native_pods.rb:301:in `react_native_post_install'
/Users/username/Desktop/Projects/nameA/App/ios/Podfile:52:in `block (3 levels) in from_ruby'
/Users/username/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-core-1.15.2/lib/cocoapods-core/podfile.rb:196:in `post_install!'
/Users/username/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:1013:in `run_podfile_post_install_hook'
/Users/username/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:1001:in `block in run_podfile_post_install_hooks'
/Users/username/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:149:in `message'
/Users/username/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:1000:in `run_podfile_post_install_hooks'
/Users/username/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:337:in `block (2 levels) in create_and_save_projects'
/Users/username/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb:61:in `write!'
/Users/username/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:336:in `block in create_and_save_projects'
/Users/username/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:64:in `section'
/Users/username/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:315:in `create_and_save_projects'
/Users/username/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:307:in `generate_pods_project'
/Users/username/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:183:in `integrate'
/Users/username/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:170:in `install!'
/Users/username/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.15.2/lib/cocoapods/command/install.rb:52:in `run'
/Users/username/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/Users/username/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.15.2/lib/cocoapods/command.rb:52:in `run'
/Users/username/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.15.2/bin/pod:55:in `<top (required)>'
/Users/username/.rbenv/versions/2.7.6/bin/pod:23:in `load'
/Users/username/.rbenv/versions/2.7.6/bin/pod:23:in `<main>'

Reproducer

https://github.com/lorenc-tomasz/rn-reproduction

Screenshots and Videos

No response

@github-actions github-actions bot added Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels May 7, 2024
@lorenc-tomasz
Copy link
Author

Mine patch file:

diff --git a/node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb b/node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb
index 7600829..7fd3d61 100644
--- a/node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb
+++ b/node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb
@@ -21,6 +21,7 @@ module PrivacyManifestUtils
         get_core_accessed_apis.each do |accessed_api|
             api_type = accessed_api["NSPrivacyAccessedAPIType"]
             reasons = accessed_api["NSPrivacyAccessedAPITypeReasons"]
+            next if api_type.nil? || reasons.nil?
             required_reason_apis[api_type] ||= []
             required_reason_apis[api_type] += reasons
         end
@@ -29,6 +30,7 @@ module PrivacyManifestUtils
         (privacy_info["NSPrivacyAccessedAPITypes"] || []).each do |accessed_api|
             api_type = accessed_api["NSPrivacyAccessedAPIType"]
             reasons = accessed_api["NSPrivacyAccessedAPITypeReasons"]
+            next if api_type.nil? || reasons.nil?
             # Add reasons from existing PrivacyInfo file to the ones from pods
             required_reason_apis[api_type] ||= []
             required_reason_apis[api_type] += reasons
@@ -67,7 +69,7 @@ module PrivacyManifestUtils
     end
 
     def self.ensure_reference(file_path, user_project, target)
-        reference_exists = target.resources_build_phase.files_references.any? { |file_ref| file_ref.path.end_with? "PrivacyInfo.xcprivacy" }
+        reference_exists = target.resources_build_phase.files_references.any? { |file_ref| file_ref.path&.end_with? "PrivacyInfo.xcprivacy" }
         unless reference_exists
             # We try to find the main group, but if it doesn't exist, we default to adding the file to the project root – both work
             file_root = user_project.root_object.main_group.children.find { |group|
@@ -79,9 +81,11 @@ module PrivacyManifestUtils
     end
 
     def self.get_privacyinfo_file_path(user_project, targets)
+        puts "Debug: Entering get_privacyinfo_file_path function"
         file_refs = targets.flat_map { |target| target.resources_build_phase.files_references }
-        existing_file = file_refs.find { |file_ref| file_ref.path.end_with? "PrivacyInfo.xcprivacy" }
+        existing_file = file_refs.find { |file_ref| file_ref.path&.end_with? "PrivacyInfo.xcprivacy" }
         if existing_file
+            puts "Debug: Found existing file: #{existing_file.real_path}"
             return existing_file.real_path
         end
 
@@ -90,9 +94,11 @@ module PrivacyManifestUtils
         if info_plist_path.nil?
             # return path that is sibling to .xcodeproj
             path = user_project.path
-            return File.join(File.dirname(path), "PrivacyInfo.xcprivacy")
+            puts "Debug: info_plist_path is nil, using user_project.path: #{path}"
+            return File.join(File.dirname(path), "PrivacyInfo.xcprivacy") unless path.nil?
         end
-        return File.join(File.dirname(info_plist_path.real_path),"PrivacyInfo.xcprivacy")
+        puts "Debug: Found info_plist_path: #{info_plist_path.real_path}"
+        return File.join(File.dirname(info_plist_path.real_path),"PrivacyInfo.xcprivacy") unless info_plist_path.real_path.nil?
     end
 
     def self.get_used_required_reason_apis(installer)
@@ -111,6 +117,7 @@ module PrivacyManifestUtils
                     accessed_api_types.each do |accessed_api|
                     api_type = accessed_api["NSPrivacyAccessedAPIType"]
                     reasons = accessed_api["NSPrivacyAccessedAPITypeReasons"]
+                    next if api_type.nil? || reasons.nil?
                     used_apis[api_type] ||= []
                     used_apis[api_type] += reasons
                     end

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels May 7, 2024
@lorenc-tomasz
Copy link
Author

lorenc-tomasz commented May 7, 2024

@aleqsio @cipolleschi can you look at this, please? :)

@github-actions github-actions bot removed the Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. label May 7, 2024
@lorenc-tomasz
Copy link
Author

Added repro repo :)

@radko93
Copy link
Contributor

radko93 commented May 8, 2024

I can confirm it's happening for me, latest Xcode and MacOs.

@soarb
Copy link

soarb commented May 8, 2024

Same for me although slightly different error:-

[Privacy Manifest Aggregation] Appending aggregated reasons to existing PrivacyInfo.xcprivacy file.
[Privacy Manifest Aggregation] Reading .xcprivacy files to aggregate all used Required Reason APIs.
[!] An error occurred while processing the post-install hook of the Podfile.

undefined method 'each' for nil:NilClass

/Users/x/Development/x/mobile_v3/node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb:111:in 'block (4 levels) in get_used_required_reason_apis'
/Users/x/Development/x/mobile_v3/node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb:106:in 'each'

Reverting back to RN 0.74.0 and all is fine.

I assume Apple will reject any submissions as we're past the 1st of May deadline for getting the privacy manifest sorted out and 0.74.0 wasn't merging these properly in the first place (from other 3rd party libs)?

@cortinico cortinico added Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. and removed Needs: Triage 🔍 Needs: Attention Issues where the author has responded to feedback. labels May 8, 2024
@cipolleschi
Copy link
Contributor

We have a fix ready with #44400. It has landed already in main, we need to release patched versions of React Native.

I'll keep the issue open for discoverability.

@lorenc-tomasz
Copy link
Author

Hi @cipolleschi,
44400 closes issue with Dic. The mentioned issue here is connected with get_privacyinfo_file_path and I have no idea why file_refs doesn't have a path property.

@aleqsio
Copy link
Contributor

aleqsio commented May 8, 2024

I think we're looking to merge #44410 to fix this issue, no?

@lorenc-tomasz
Copy link
Author

lorenc-tomasz commented May 8, 2024

Thank you for answer @aleqsio. I didn't notice this PR :(

@david-cahill
Copy link

@cipolleschi Any idea when this might be released? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project.
Projects
None yet
Development

No branches or pull requests

7 participants