react-native
react-native copied to clipboard
Priavacy Policy aggregation errors on get_privacyinfo_file_path
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
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
@aleqsio @cipolleschi can you look at this, please? :)
Added repro repo :)
I can confirm it's happening for me, latest Xcode and MacOs.
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)?
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.
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.
I think we're looking to merge https://github.com/facebook/react-native/pull/44410 to fix this issue, no?
Thank you for answer @aleqsio. I didn't notice this PR :(
@cipolleschi Any idea when this might be released? Thanks!
@david-cahill Likely next week. We have been busy working on the React Conf the past two weeks, so we could not dedicate any time to anything else, unfortunately. This week we have internal events plus the AppJS conf that are going to slow down the releases a bit. Next week we should be back to normal.
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)?
I am seeing the same error, and this has not been fixed by the linked PRs, so here is another one for this specific issue (manifest without a NSPrivacyAccessedAPITypes
key): https://github.com/facebook/react-native/pull/44628
@david-cahill Likely next week. We have been busy working on the React Conf the past two weeks, so we could not dedicate any time to anything else, unfortunately. This week we have internal events plus the AppJS conf that are going to slow down the releases a bit. Next week we should be back to normal.
I wanted to go to the App JS conference (2 hours by car) but the company refused my request :(
For me this did the fix:
next if accessed_api_types.nil? || accessed_api_types.nil?
so .. this was an issue for the react-native-maps project as well, it seems like by updating to react-native 0.74.1 from react-native 0.74.0 there are more strict checks for privacy manifest file content, ie both NSPrivacyCollectedDataTypes and NSPrivacyAccessedAPITypes were needed.
we included both and pod install is now working as expected.
so I'm not sure if this is really a bug in react-native itself or simply a better PrivacyPolicy file is expected
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
thanks @lorenc-tomasz patch also worked for me
Version 0.74.2 of React Native is out with all the fixes to the privacy manifest. Patches for versions 0.73 and 0.72 will come in the next few days with similar fixes!
Thanks @cipolleschi, I updated and it's all good!
Hello,
I am getting the same error message even tho I have RN 0.74.3, what could be causing the issue!?
Thanks
@mo-elnady you might have a stale version cached. Can you try to run:
# from the ios folder
bundle exec pod deintegrate
cd ..
rm -rf node_modules
yarn install
cd ios
bundle exec pod install
This should reset your node_modules and pods.