Cocoapods: NoMethodError - undefined method `each' for nil:NilClass

Created on 10 Oct 2019  ยท  8Comments  ยท  Source: CocoaPods/CocoaPods

same error in 1.7.1, 1.8.0, and 1.8.3

NoMethodError - undefined method `each' for nil:NilClass
/Users/davidgobaud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.8.0/lib/cocoapods/installer/analyzer/locking_dependency_analyzer.rb:96:in `block in add_to_dependency_graph'
/Users/davidgobaud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.8.0/lib/cocoapods/installer/analyzer/locking_dependency_analyzer.rb:94:in `each'
/Users/davidgobaud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.8.0/lib/cocoapods/installer/analyzer/locking_dependency_analyzer.rb:94:in `add_to_dependency_graph'
/Users/davidgobaud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.8.0/lib/cocoapods/installer/analyzer/locking_dependency_analyzer.rb:45:in `block in generate_version_locking_dependencies'
/Users/davidgobaud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.8.0/lib/cocoapods/installer/analyzer/locking_dependency_analyzer.rb:44:in `each'
/Users/davidgobaud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.8.0/lib/cocoapods/installer/analyzer/locking_dependency_analyzer.rb:44:in `generate_version_locking_dependencies'
/Users/davidgobaud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.8.0/lib/cocoapods/installer/analyzer.rb:849:in `generate_version_locking_dependencies'
/Users/davidgobaud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.8.0/lib/cocoapods/installer/analyzer.rb:123:in `analyze'
/Users/davidgobaud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.8.0/lib/cocoapods/installer.rb:410:in `analyze'
/Users/davidgobaud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.8.0/lib/cocoapods/installer.rb:234:in `block in resolve_dependencies'
/Users/davidgobaud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.8.0/lib/cocoapods/user_interface.rb:64:in `section'
/Users/davidgobaud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.8.0/lib/cocoapods/installer.rb:233:in `resolve_dependencies'
/Users/davidgobaud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.8.0/lib/cocoapods/installer.rb:156:in `install!'
/Users/davidgobaud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.8.0/lib/cocoapods/command/install.rb:52:in `run'
/Users/davidgobaud/.rvm/gems/ruby-2.6.3/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Users/davidgobaud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.8.0/lib/cocoapods/command.rb:52:in `run'
/Users/davidgobaud/.rvm/gems/ruby-2.6.3/gems/cocoapods-1.8.0/bin/pod:55:in `<top (required)>'
/Users/davidgobaud/.rvm/gems/ruby-2.6.3/bin/pod:23:in `load'
/Users/davidgobaud/.rvm/gems/ruby-2.6.3/bin/pod:23:in `<main>'
/Users/davidgobaud/.rvm/gems/ruby-2.6.3/bin/ruby_executable_hooks:24:in `eval'
/Users/davidgobaud/.rvm/gems/ruby-2.6.3/bin/ruby_executable_hooks:24:in `<main>'

Most helpful comment

In case anybody else gets this error and is routed here:

You will see this error if you've had a bad merge on your Podfile.lock. Specifically, when I saw the issue, it was because there was a trailing colon ":" on a pod line like so:

...
  - SomePod (1.0.0):
    - SomeDependency
  - TheProblemLine (0.0.1):
  - YetAnotherPod (2.0.0):
    - MoreDepdencies
...

You can delete that errant line and then re-run pod install to recreate a working Podfile.lock.

All 8 comments

There is insufficient information for us to diagnose this issue. Please provide a sample app and steps to reproduce.

Going to close preemptively until a sample app or steps to reproduce are included since we are getting a high volume of issues.

@dnkoutso same issue I'm facing

project-103524:ios bhumin3imac$ pod install

Analyzing dependencies

โ€•โ€•โ€• MARKDOWN TEMPLATE โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•

Command

/Users/bhumin3imac/.gem/bin/pod install

Report

  • What did you do?

  • What did you expect to happen?

  • What happened instead?

Stack

   CocoaPods : 1.8.4
        Ruby : ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
    RubyGems : 2.5.2.3
        Host : Mac OS X 10.14.6 (18G1012)
       Xcode : 11.2 (11B52)
         Git : git version 2.21.0 (Apple Git-122.2)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib
Repositories : 

Plugins

cocoapods-deintegrate : 1.0.4
cocoapods-plugins     : 1.0.0
cocoapods-search      : 1.0.0
cocoapods-stats       : 1.1.0
cocoapods-trunk       : 1.4.1
cocoapods-try         : 1.1.0

Podfile

# DO NOT MODIFY -- auto-generated by Apache Cordova

platform :ios, '11.0'

target '@FirebaseApp' do
    project '@FirebaseApp.xcodeproj'
    pod 'FirebaseMessaging', '~> 2.0.0'
end

Error

NoMethodError - undefined method `[]' for nil:NilClass
/Library/Ruby/Gems/2.3.0/gems/xcodeproj-1.13.0/lib/xcodeproj/project.rb:265:in `new_from_plist'
/Library/Ruby/Gems/2.3.0/gems/xcodeproj-1.13.0/lib/xcodeproj/project.rb:212:in `initialize_from_file'
/Library/Ruby/Gems/2.3.0/gems/xcodeproj-1.13.0/lib/xcodeproj/project.rb:112:in `open'
/Users/bhumin3imac/.gem/gems/cocoapods-1.8.4/lib/cocoapods/installer/analyzer.rb:1098:in `block (2 levels) in inspect_targets_to_integrate'
/Users/bhumin3imac/.gem/gems/cocoapods-1.8.4/lib/cocoapods/installer/analyzer.rb:1097:in `each'
/Users/bhumin3imac/.gem/gems/cocoapods-1.8.4/lib/cocoapods/installer/analyzer.rb:1097:in `block in inspect_targets_to_integrate'
/Users/bhumin3imac/.gem/gems/cocoapods-1.8.4/lib/cocoapods/user_interface.rb:64:in `section'
/Users/bhumin3imac/.gem/gems/cocoapods-1.8.4/lib/cocoapods/installer/analyzer.rb:1092:in `inspect_targets_to_integrate'
/Users/bhumin3imac/.gem/gems/cocoapods-1.8.4/lib/cocoapods/installer/analyzer.rb:106:in `analyze'
/Users/bhumin3imac/.gem/gems/cocoapods-1.8.4/lib/cocoapods/installer.rb:410:in `analyze'
/Users/bhumin3imac/.gem/gems/cocoapods-1.8.4/lib/cocoapods/installer.rb:234:in `block in resolve_dependencies'
/Users/bhumin3imac/.gem/gems/cocoapods-1.8.4/lib/cocoapods/user_interface.rb:64:in `section'
/Users/bhumin3imac/.gem/gems/cocoapods-1.8.4/lib/cocoapods/installer.rb:233:in `resolve_dependencies'
/Users/bhumin3imac/.gem/gems/cocoapods-1.8.4/lib/cocoapods/installer.rb:156:in `install!'
/Users/bhumin3imac/.gem/gems/cocoapods-1.8.4/lib/cocoapods/command/install.rb:52:in `run'
/Library/Ruby/Gems/2.3.0/gems/claide-1.0.3/lib/claide/command.rb:334:in `run'
/Users/bhumin3imac/.gem/gems/cocoapods-1.8.4/lib/cocoapods/command.rb:52:in `run'
/Users/bhumin3imac/.gem/gems/cocoapods-1.8.4/bin/pod:55:in `<top (required)>'
/Users/bhumin3imac/.gem/bin/pod:22:in `load'
/Users/bhumin3imac/.gem/bin/pod:22:in `<main>'

โ€•โ€•โ€• TEMPLATE END โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•โ€•

[!] Oh no, an error occurred.

Search for existing GitHub issues similar to yours:
https://github.com/CocoaPods/CocoaPods/search?q=undefined+method+%60%5B%5D%27+for+nil%3ANilClass&type=Issues

If none exists, create a ticket, with the template displayed above, on:
https://github.com/CocoaPods/CocoaPods/issues/new

Be sure to first read the contributing guide for details on how to properly submit a ticket:
https://github.com/CocoaPods/CocoaPods/blob/master/CONTRIBUTING.md

Don't forget to anonymize any private data!

Looking for related issues on cocoapods/cocoapods...

and 206 more at:
https://github.com/cocoapods/cocoapods/search?q=undefined%20method%20%60%5B%5D%27%20for%20nil&type=Issues&utf8=โœ“

In case anybody else gets this error and is routed here:

You will see this error if you've had a bad merge on your Podfile.lock. Specifically, when I saw the issue, it was because there was a trailing colon ":" on a pod line like so:

...
  - SomePod (1.0.0):
    - SomeDependency
  - TheProblemLine (0.0.1):
  - YetAnotherPod (2.0.0):
    - MoreDepdencies
...

You can delete that errant line and then re-run pod install to recreate a working Podfile.lock.

In case anybody else gets this error and is routed here:

You will see this error if you've had a bad merge on your Podfile.lock. Specifically, when I saw the issue, it was because there was a trailing colon ":" on a pod line like so:

...
  - SomePod (1.0.0):
    - SomeDependency
  - TheProblemLine (0.0.1):
  - YetAnotherPod (2.0.0):
    - MoreDepdencies
...

You can delete that errant line and then re-run pod install to recreate a working Podfile.lock.

@cchamb-gh Thanks!
You saved my day!

@cchamb-gh 's solution really worked perfectly for me. I deleted the unnecessary semi-colon (which is used to indicate that the following packages, which are normally indented, are dependencies) and ran pod install. The dependency was added automatic and everything worked.

I deleted Podfile.lock and ran pod install and it didn't solve it for me.

flutter clean
flutter pub get
pod install
problem solving

The @cchamb-gh is right.
You only need to remove the semi-colon from items without children.

For example: On this case, you only need to remove the semi-colon from TheProblemLine (0.0.1).

...
  - SomePod (1.0.0):
    - SomeDependency
  - TheProblemLine (0.0.1):
  - YetAnotherPod (2.0.0):
    - MoreDepdencies
...
Was this page helpful?
0 / 5 - 0 ratings