CocoaPods / CocoaPods

The Cocoa Dependency Manager.
https://cocoapods.org/
Other
14.47k stars 2.62k forks source link

pod install not working #12407

Open ndevev opened 2 weeks ago

ndevev commented 2 weeks ago

Command

/usr/local/bin/pod install

Report

Stack

   CocoaPods : 1.15.2
        Ruby : ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.arm64e-darwin23]
    RubyGems : 3.0.3.1
        Host : macOS 14.5 (23F79)
       Xcode : 15.4 (15F31d)
         Git : git version 2.39.3 (Apple Git-146)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib
Repositories : trunk - CDN - https://cdn.cocoapods.org/

Plugins

cocoapods-deintegrate : 1.0.5
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.1
cocoapods-trunk       : 1.6.0
cocoapods-try         : 1.2.0

Podfile

# Uncomment this line to define a global platform for your project
platform :ios, '12.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
end

Error

REXML::ParseException - #<TypeError: wrong argument type String (expected Regexp)>
/Library/Ruby/Gems/2.6.0/gems/rexml-3.2.9/lib/rexml/source.rb:220:in `scan'
/Library/Ruby/Gems/2.6.0/gems/rexml-3.2.9/lib/rexml/source.rb:220:in `match'
/Library/Ruby/Gems/2.6.0/gems/rexml-3.2.9/lib/rexml/parsers/baseparser.rb:227:in `pull_event'
/Library/Ruby/Gems/2.6.0/gems/rexml-3.2.9/lib/rexml/parsers/baseparser.rb:207:in `pull'
/Library/Ruby/Gems/2.6.0/gems/rexml-3.2.9/lib/rexml/parsers/treeparser.rb:23:in `parse'
/Library/Ruby/Gems/2.6.0/gems/rexml-3.2.9/lib/rexml/document.rb:448:in `build'
/Library/Ruby/Gems/2.6.0/gems/rexml-3.2.9/lib/rexml/document.rb:101:in `initialize'
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.24.0/lib/xcodeproj/workspace.rb:83:in `new'
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.24.0/lib/xcodeproj/workspace.rb:83:in `from_s'
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.24.0/lib/xcodeproj/workspace.rb:66:in `new_from_xcworkspace'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/user_project_integrator.rb:102:in `create_workspace'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/user_project_integrator.rb:71:in `integrate!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:929:in `block in integrate_user_project'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:925:in `integrate_user_project'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:185:in `integrate'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:170:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/command/install.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'
...
wrong argument type String (expected Regexp)
Line: 1
Position: 38
Last 80 unconsumed characters:
<?xml version="1.0" encoding="UTF-8"?>
/Library/Ruby/Gems/2.6.0/gems/rexml-3.2.9/lib/rexml/parsers/treeparser.rb:96:in `rescue in parse'
/Library/Ruby/Gems/2.6.0/gems/rexml-3.2.9/lib/rexml/parsers/treeparser.rb:21:in `parse'
/Library/Ruby/Gems/2.6.0/gems/rexml-3.2.9/lib/rexml/document.rb:448:in `build'
/Library/Ruby/Gems/2.6.0/gems/rexml-3.2.9/lib/rexml/document.rb:101:in `initialize'
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.24.0/lib/xcodeproj/workspace.rb:83:in `new'
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.24.0/lib/xcodeproj/workspace.rb:83:in `from_s'
/Library/Ruby/Gems/2.6.0/gems/xcodeproj-1.24.0/lib/xcodeproj/workspace.rb:66:in `new_from_xcworkspace'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/user_project_integrator.rb:102:in `create_workspace'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer/user_project_integrator.rb:71:in `integrate!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:929:in `block in integrate_user_project'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/user_interface.rb:64:in `section'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:925:in `integrate_user_project'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:185:in `integrate'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/installer.rb:170:in `install!'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/command/install.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/claide-1.1.0/lib/claide/command.rb:334:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/lib/cocoapods/command.rb:52:in `run'
/Library/Ruby/Gems/2.6.0/gems/cocoapods-1.15.2/bin/pod:55:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'
f-pennacchio commented 2 weeks ago

I have the exact issue; trying to recompile and build a project for customer after clean mac sonoma install ad installing xcode 15.4

Stack

   CocoaPods : 1.11.3
        Ruby : ruby 2.6.0p0 (2018-12-25 revision 66547) [x86_64-darwin23]
    RubyGems : 3.0.1
        Host : macOS 14.4.1 (23E224)
       Xcode : 15.4 (15F31d)
         Git : git version 2.39.3 (Apple Git-146)
Ruby lib dir : /Users/Stefano/.rbenv/versions/2.6.0/lib
Repositories : trunk - CDN - https://cdn.cocoapods.org/

Error

REXML::ParseException - #<TypeError: wrong argument type String (expected Regexp)>
f-pennacchio commented 2 weeks ago

The issue seems to be related to rexml: https://github.com/ruby/rexml/issues/142 rexml has been updated to fix the issue in new version 3.3.0 I don't know how to force cocoapods to use new library version, can someone please indicate how to do it?

@ndevev

anusha-chromosis commented 2 weeks ago

I am also having same exact issue ,have been trying this for hours

f-pennacchio commented 2 weeks ago

@ndevev @anusha-chromosis I managed to complete pod install. Here the steps:

kou commented 2 weeks ago

https://github.com/CocoaPods/Xcodeproj/pull/944 will solve this.

kou commented 2 weeks ago

Could you show the output of gem list?

The following command lines may be another workaround:

$ sudo gem install rexml -v 3.2.6
$ sudo gem uninstall rexml -v 3.2.9

The following command lines may be another workaround:

$ sudo gem install strscan
arturoacsan commented 2 weeks ago

The context of my problem was that I was getting the error while running a Flutter app with plugins. The default one didn't gave me any problem. Also, I was getting the exact same issue that the original issue poster, same Ruby version, same lines, etc., but on an M1 device.

In my situation, the problem was solve once I removed cocoapods completely and then installed it again. I'm a new MacOS user so I think this was my fault while trying to configure my environment.

I remove it using: $ brew uninstall cocoapods

But I was still getting a result while executing: $ pod --version

Then I use: $ which pod

To find the path of the pods installation that was still on the computer.

So I executed: sudo rm /usr/local/bin/pod

Then I run pod --version to make sure it was completely deleted. I installed it again using: $ brew install cocoapods

Then I run the app again and it worked. Hope this helps someone.

ndevev commented 1 week ago

It happened when I was trying to set up a new MacBook Air. I couldn't solve it so I went back to the factory default and then migrated everything from my old one. And this worked well. So I can't send the gem list. Anyway, thanks to everyone, the suggestions here will come in handy later.

xiaodi0003 commented 2 days ago

Could you show the output of gem list?

The following command lines may be another workaround:

$ sudo gem install rexml -v 3.2.6
$ sudo gem uninstall rexml -v 3.2.9

The following command lines may be another workaround:

$ sudo gem install strscan

great, thx

monfresh commented 1 day ago

The reason you're seeing this error is because you're using the system Ruby (the Ruby version that came preinstalled on your Mac), or a version of Ruby older than 3.x that you installed yourself. Instead, I highly recommend using a version manager (such as chruby, rbenv, asdf) to install a newer and separate Ruby version that won't have this rexml issue.

The solutions offered here so far might work, but they are far from ideal, and can cause other issues. I've written popular articles that explain Why You Should Never Use sudo to Install Ruby Gems and Why You Shouldn't Use the System Ruby to Install Gems on a Mac.

To understand why this REXML error happens with older Ruby versions, and how to properly install a newer version of Ruby, read my latest article: How to fix REXML::ParseException TypeError in Cocoapods.