Skip to content

Commit 115331b

Browse files
swrobelgabrieldonadel
authored andcommitted
Add nil check to privacy manifest generation (#44400)
Summary: After upgrading my app from React Native 0.74.0 to 0.74.1, iOS builds were failing due to the privacy manifest ruby script failing due to what seemed to be a missing nil check. ``` [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. no implicit conversion of nil into Array node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb:115:in `+' node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb:115:in `block (5 levels) in get_used_required_reason_apis' node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb:111:in `each' node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb:111:in `block (4 levels) in get_used_required_reason_apis' node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb:106:in `each' node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb:106:in `block (3 levels) in get_used_required_reason_apis' node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb:105:in `each' node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb:105:in `block (2 levels) in get_used_required_reason_apis' node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb:104:in `each' node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb:104:in `block in get_used_required_reason_apis' node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb:102:in `each' node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb:102:in `get_used_required_reason_apis' node_modules/react-native/scripts/cocoapods/privacy_manifest_utils.rb:18:in `add_aggregated_privacy_manifest' node_modules/react-native/scripts/react_native_pods.rb:301:in `react_native_post_install' ios/Podfile:38:in `block (3 levels) in from_ruby' vendor/bundle/ruby/3.3.0/gems/cocoapods-core-1.15.2/lib/cocoapods-core/podfile.rb:196:in `post_install!' vendor/bundle/ruby/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:1013:in `run_podfile_post_install_hook' vendor/bundle/ruby/3.3.0/gems/cocoapods-pod-sign-1.3.0/lib/cocoapods-pod-sign/pod_installer.rb:45:in `run_podfile_post_install_hook' vendor/bundle/ruby/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:1001:in `block in run_podfile_post_install_hooks' vendor/bundle/ruby/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:149:in `message' vendor/bundle/ruby/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:1000:in `run_podfile_post_install_hooks' vendor/bundle/ruby/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:337:in `block (2 levels) in create_and_save_projects' vendor/bundle/ruby/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb:61:in `write!' vendor/bundle/ruby/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:336:in `block in create_and_save_projects' vendor/bundle/ruby/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:64:in `section' vendor/bundle/ruby/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:315:in `create_and_save_projects' vendor/bundle/ruby/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:307:in `generate_pods_project' vendor/bundle/ruby/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:183:in `integrate' vendor/bundle/ruby/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:170:in `install!' vendor/bundle/ruby/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/command/update.rb:63:in `run' vendor/bundle/ruby/3.3.0/gems/claide-1.1.0/lib/claide/command.rb:334:in `run' vendor/bundle/ruby/3.3.0/gems/cocoapods-1.15.2/lib/cocoapods/command.rb:52:in `run' vendor/bundle/ruby/3.3.0/gems/cocoapods-1.15.2/bin/pod:55:in `<top (required)>' vendor/bundle/ruby/3.3.0/bin/pod:25:in `load' vendor/bundle/ruby/3.3.0/bin/pod:25:in `<top (required)>' /Users/swrobel/.gem/ruby/3.3.1/gems/bundler-2.5.9/lib/bundler/cli/exec.rb:58:in `load' /Users/swrobel/.gem/ruby/3.3.1/gems/bundler-2.5.9/lib/bundler/cli/exec.rb:58:in `kernel_load' /Users/swrobel/.gem/ruby/3.3.1/gems/bundler-2.5.9/lib/bundler/cli/exec.rb:23:in `run' /Users/swrobel/.gem/ruby/3.3.1/gems/bundler-2.5.9/lib/bundler/cli.rb:451:in `exec' /Users/swrobel/.gem/ruby/3.3.1/gems/bundler-2.5.9/lib/bundler/vendor/thor/lib/thor/command.rb:28:in `run' /Users/swrobel/.gem/ruby/3.3.1/gems/bundler-2.5.9/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command' /Users/swrobel/.gem/ruby/3.3.1/gems/bundler-2.5.9/lib/bundler/vendor/thor/lib/thor.rb:527:in `dispatch' /Users/swrobel/.gem/ruby/3.3.1/gems/bundler-2.5.9/lib/bundler/cli.rb:34:in `dispatch' /Users/swrobel/.gem/ruby/3.3.1/gems/bundler-2.5.9/lib/bundler/vendor/thor/lib/thor/base.rb:584:in `start' /Users/swrobel/.gem/ruby/3.3.1/gems/bundler-2.5.9/lib/bundler/cli.rb:28:in `start' /Users/swrobel/.gem/ruby/3.3.1/gems/bundler-2.5.9/exe/bundle:28:in `block in <top (required)>' /Users/swrobel/.gem/ruby/3.3.1/gems/bundler-2.5.9/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors' /Users/swrobel/.gem/ruby/3.3.1/gems/bundler-2.5.9/exe/bundle:20:in `<top (required)>' /Users/swrobel/.gem/ruby/3.3.1/bin/bundle:25:in `load' /Users/swrobel/.gem/ruby/3.3.1/bin/bundle:25:in `<main>' ``` Adding some good old `puts` debugging to this file indicated that the problem was that an invalid manifest file was being generated for react-native-image-crop-picker, which I don't understand, because it [doesn't currently have a Privacy Manifest](ivpusic/react-native-image-crop-picker#2040). ```xml <?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>NSPrivacyTracking</key> <false/> <key>NSPrivacyTrackingDomains</key> <array/> <key>NSPrivacyCollectedDataTypes</key> <array/> <key>NSPrivacyAccessedAPITypes</key> <array> <dict/> </array> </dict> </plist> ``` It seems there may be some upstream issue in whatever tool generates these missing privacy manifests, but that seemed beyond the scope of a simple nil check. ## Changelog: [iOS] [FIXED] - Privacy Manifest aggregation failing due to missing nil check Pull Request resolved: #44400 Test Plan: Build completes successfully after making this change. Reviewed By: cipolleschi Differential Revision: D56921303 Pulled By: philIip fbshipit-source-id: 1b6b10b05d403bf71f78f5b80543a2d82f043e23
1 parent 6983a8b commit 115331b

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

packages/react-native/scripts/cocoapods/privacy_manifest_utils.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,11 @@ def self.get_used_required_reason_apis(installer)
106106
content = Xcodeproj::Plist.read_from_path(file_path)
107107
accessed_api_types = content["NSPrivacyAccessedAPITypes"]
108108
accessed_api_types.each do |accessed_api|
109-
api_type = accessed_api["NSPrivacyAccessedAPIType"]
110-
reasons = accessed_api["NSPrivacyAccessedAPITypeReasons"]
111-
used_apis[api_type] ||= []
112-
used_apis[api_type] += reasons
109+
api_type = accessed_api["NSPrivacyAccessedAPIType"]
110+
reasons = accessed_api["NSPrivacyAccessedAPITypeReasons"]
111+
next unless api_type
112+
used_apis[api_type] ||= []
113+
used_apis[api_type] += reasons
113114
end
114115
end
115116
end

0 commit comments

Comments
 (0)