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

update_ats_in_plist in cocoapods/utils.rb fails to correctly resolve the file names of plist files added in targets, causing pod install failures #42239

Closed
chriszs opened this issue Jan 11, 2024 · 1 comment
Labels
Resolution: Fixed A PR that fixes this issue has been merged.

Comments

@chriszs
Copy link

chriszs commented Jan 11, 2024

Description

The update_ats_in_plist method in cocoapods/utils.rb added in #38086 fails to correctly resolve the file names of plist files added in targets, causing pod install failures.

The error message I get is "The plist file at path [...] ReproducerApp/ios/NotificationServiceExtension-Info.plist doesn't exist." The file does exist, but not at that path. update_ats looks at the wrong path.

The logic issue seems to be triggered when the name field is added to the PBXFileReference (the name field is what update_ats looks at to determine whether the file is an Info.plist file), which in my testing Xcode didn't add by default (though there may be some circumstance in which it does) but common tooling in the React Native ecosystem which uses the addPbxGroup method of the xcode NPM package does consistently add the name field and it appears to be a standard PBXFileReference field.

The correct resolution, as demonstrated by Xcode on another project, finds the Info.plist file in the target/group:
Screenshot 2024-01-11 at 2 38 12 PM

@EvanBacon notes some of this thoughts on how to improve the logic here.

Steps to reproduce

  1. I created a new repo using the reproducer-react-native template
  2. I cloned the repo
  3. I ran yarn install
  4. I opened the ios/ directory in Xcode and added a new target with File > New > Target > Notification Service Extension
  5. I renamed the resulting Info.plist file and then I hand-modified project.pbx to added a name field that matched the file name (this was done by hand for minimal reproduction purposes, but is encountered out in the wild without a manual step)
  6. I ran npx pod-install

React Native Version

0.73.2

Affected Platforms

Build - MacOS

Output of npx react-native info

System:
  OS: macOS 14.2.1
  CPU: (8) arm64 Apple M2
  Memory: 82.94 MB / 8.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.2.0
    path: ~/.asdf/installs/nodejs/20.2.0/bin/node
  Yarn:
    version: 1.22.21
    path: ~/.asdf/installs/nodejs/20.2.0/bin/yarn
  npm:
    version: 9.6.6
    path: ~/.asdf/plugins/nodejs/shims/npm
  Watchman:
    version: 2023.12.04.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.14.3
    path: /Users/admin/.asdf/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.2
      - iOS 17.2
      - macOS 14.2
      - tvOS 17.2
      - watchOS 10.2
  Android SDK: Not Found
IDEs:
  Android Studio: 2023.1 AI-231.9392.1.2311.11076708
  Xcode:
    version: 15.1/15C65
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.20
    path: /Users/admin/.asdf/shims/javac
  Ruby:
    version: 2.7.6
    path: /Users/admin/.asdf/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.2
    wanted: 0.73.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

Command `pod install` failed.
└─ Cause: An error occurred while processing the post-install hook of the Podfile.

[!] The plist file at path `/Users/admin/Desktop/work/chriszs/reproducer-react-native/ReproducerApp/ios/NotificationServiceExtension-Info.plist` doesn't exist.


/Users/admin/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/xcodeproj-1.23.0/lib/xcodeproj/plist.rb:17:in `read_from_path'
/Users/admin/Desktop/work/chriszs/reproducer-react-native/ReproducerApp/node_modules/react-native/scripts/cocoapods/utils.rb:553:in `block in update_ats_in_plist'
/Users/admin/Desktop/work/chriszs/reproducer-react-native/ReproducerApp/node_modules/react-native/scripts/cocoapods/utils.rb:551:in `each'
/Users/admin/Desktop/work/chriszs/reproducer-react-native/ReproducerApp/node_modules/react-native/scripts/cocoapods/utils.rb:551:in `update_ats_in_plist'
/Users/admin/Desktop/work/chriszs/reproducer-react-native/ReproducerApp/node_modules/react-native/scripts/cocoapods/utils.rb:575:in `apply_ats_config'
/Users/admin/Desktop/work/chriszs/reproducer-react-native/ReproducerApp/node_modules/react-native/scripts/react_native_pods.rb:310:in `react_native_post_install'
/Users/admin/Desktop/work/chriszs/reproducer-react-native/ReproducerApp/ios/Podfile:49:in `block (3 levels) in from_ruby'
/Users/admin/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-core-1.14.3/lib/cocoapods-core/podfile.rb:196:in `post_install!'
/Users/admin/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:1013:in `run_podfile_post_install_hook'
/Users/admin/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:1001:in `block in run_podfile_post_install_hooks'
/Users/admin/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.14.3/lib/cocoapods/user_interface.rb:149:in `message'
/Users/admin/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:1000:in `run_podfile_post_install_hooks'
/Users/admin/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:337:in `block (2 levels) in create_and_save_projects'
/Users/admin/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.14.3/lib/cocoapods/installer/xcode/pods_project_generator/pods_project_writer.rb:61:in `write!'
/Users/admin/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:336:in `block in create_and_save_projects'
/Users/admin/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.14.3/lib/cocoapods/user_interface.rb:64:in `section'
/Users/admin/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:315:in `create_and_save_projects'
/Users/admin/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:307:in `generate_pods_project'
/Users/admin/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:183:in `integrate'
/Users/admin/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.14.3/lib/cocoapods/installer.rb:170:in `install!'
/Users/admin/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.14.3/lib/cocoapods/command/install.rb:52:in `run'
/Users/admin/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/Users/admin/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.14.3/lib/cocoapods/command.rb:52:in `run'
/Users/admin/.asdf/installs/ruby/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.14.3/bin/pod:55:in `<top (required)>'
/Users/admin/.asdf/installs/ruby/2.7.6/bin/pod:23:in `load'
/Users/admin/.asdf/installs/ruby/2.7.6/bin/pod:23:in `<main>'

Reproducer

chriszs/reproducer-react-native#1

@chriszs
Copy link
Author

chriszs commented Feb 1, 2024

Fixed in 0.73.3.

@chriszs chriszs closed this as completed Feb 1, 2024
@cortinico cortinico added Resolution: Fixed A PR that fixes this issue has been merged. and removed Needs: Triage 🔍 labels Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Fixed A PR that fixes this issue has been merged.
Projects
None yet
Development

No branches or pull requests

2 participants