Skip to content

undefined method `path' for nil:NilClass #4887

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

Closed
nilsen340 opened this issue Feb 11, 2016 · 17 comments
Closed

undefined method `path' for nil:NilClass #4887

nilsen340 opened this issue Feb 11, 2016 · 17 comments
Labels
d1:easy An easy ticket that is a good start for first-time contributors s3:detailed Issues with in-depth explanations and examples that make it easier to troubleshoot t2:defect These are known bugs. The issue should also contain steps to reproduce. PRs welcome!

Comments

@nilsen340
Copy link

Command

/usr/local/bin/pod install

Report

  • What did you do?
    I'm creating a framework with this podspec:
Pod::Spec.new do |s|
  s.name             = "elements"
  s.version          = "0.1.0"
  s.summary          = "A short description of elements."
  s.license          = 'MIT'
  s.author           = { "John Nilsen" => "nilsen340@gmail.com" }
  s.source           = { :git => "https://github.com/<GITHUB_USERNAME>/elements.git", :tag => s.version.to_s }

  s.homepage = 'https://github.com/nilsen340/'
  s.platform     = :ios, '8.0'
  s.requires_arc = true

  s.source_files = 'Pod/Classes/**/*'
  s.resource_bundles = {
    'elements' => ['Pod/Classes/**/*']
  }
  s.dependency 'Tapglue', '1.1.0'
end
  • What did you expect to happen?

It to build the example app correctly

  • What happened instead?

this error

Stack

   CocoaPods : 1.0.0.beta.3
        Ruby : ruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]
    RubyGems : 2.0.14
        Host : Mac OS X 10.11.3 (15D21)
       Xcode : 7.2 (7C68)
         Git : git version 2.5.4 (Apple Git-61)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib
Repositories : master - https://github.com/CocoaPods/Specs.git @ 006cdb619e535e2889c045e988231fd3aadcd18f

Plugins

cocoapods-deintegrate : 1.0.0.beta.1
cocoapods-plugins     : 1.0.0.beta.1
cocoapods-search      : 1.0.0.beta.1
cocoapods-stats       : 1.0.0.beta.3
cocoapods-trunk       : 1.0.0.beta.2
cocoapods-try         : 1.0.0.beta.2

Podfile

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

target 'elements_Example' do
  pod 'elements', :path => '../'
  pod 'Tapglue'
end

#target 'elements_Tests' do
#  pod 'elements', :path => '../'
#
#  pod 'Quick', '~> 0.8.0'
#  pod 'Nimble', '3.0.0'
#  pod 'FBSnapshotTestCase'
#  pod 'Nimble-Snapshots'
#end

Error

NoMethodError - undefined method `path' for nil:NilClass
/Library/Ruby/Gems/2.0.0/gems/xcodeproj-1.0.0.beta.2/lib/xcodeproj/project/object/native_target.rb:442:in `block in add_file_references'
/Library/Ruby/Gems/2.0.0/gems/xcodeproj-1.0.0.beta.2/lib/xcodeproj/project/object/native_target.rb:441:in `map'
/Library/Ruby/Gems/2.0.0/gems/xcodeproj-1.0.0.beta.2/lib/xcodeproj/project/object/native_target.rb:441:in `add_file_references'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.0.0.beta.3/lib/cocoapods/installer/target_installer/pod_target_installer.rb:99:in `block in add_files_to_build_phases'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.0.0.beta.3/lib/cocoapods/installer/target_installer/pod_target_installer.rb:75:in `each'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.0.0.beta.3/lib/cocoapods/installer/target_installer/pod_target_installer.rb:75:in `add_files_to_build_phases'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.0.0.beta.3/lib/cocoapods/installer/target_installer/pod_target_installer.rb:21:in `block in install!'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.0.0.beta.3/lib/cocoapods/user_interface.rb:144:in `message'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.0.0.beta.3/lib/cocoapods/installer/target_installer/pod_target_installer.rb:17:in `install!'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.0.0.beta.3/lib/cocoapods/installer.rb:634:in `block (2 levels) in install_libraries'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.0.0.beta.3/lib/cocoapods/installer.rb:631:in `each'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.0.0.beta.3/lib/cocoapods/installer.rb:631:in `block in install_libraries'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.0.0.beta.3/lib/cocoapods/user_interface.rb:144:in `message'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.0.0.beta.3/lib/cocoapods/installer.rb:630:in `install_libraries'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.0.0.beta.3/lib/cocoapods/installer.rb:166:in `block in generate_pods_project'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.0.0.beta.3/lib/cocoapods/user_interface.rb:63:in `section'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.0.0.beta.3/lib/cocoapods/installer.rb:163:in `generate_pods_project'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.0.0.beta.3/lib/cocoapods/installer.rb:115:in `install!'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.0.0.beta.3/lib/cocoapods/command/project.rb:67:in `run_install_with_update'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.0.0.beta.3/lib/cocoapods/command/project.rb:97:in `run'
/Library/Ruby/Gems/2.0.0/gems/claide-1.0.0.beta.1/lib/claide/command.rb:312:in `run'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.0.0.beta.3/lib/cocoapods/command.rb:48:in `run'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-1.0.0.beta.3/bin/pod:44:in `<top (required)>'
/usr/local/bin/pod:23:in `load'
/usr/local/bin/pod:23:in `<main>'
@segiddins
Copy link
Member

Can you share a project we can run pod install on that will reproduce the issue? Thanks!

@segiddins segiddins added the s1:awaiting input Waiting for input from the original author label Feb 11, 2016
@nilsen340
Copy link
Author

https://github.com/tapglue/elements-ios

ui-kit branch

@segiddins segiddins removed the s1:awaiting input Waiting for input from the original author label Feb 11, 2016
@segiddins
Copy link
Member

The error I get is as follows, which is unrelated. (using beta 3)

[!] The `elements` pod failed to validate due to 1 error:
    - ERROR | attributes: Missing required attribute `homepage`.
    - WARN  | summary: The summary is not meaningful.

@segiddins segiddins added s1:awaiting input Waiting for input from the original author s4:awaiting validation A Pull Request that is waiting for validation by a CocoaPods Core Team member and removed s1:awaiting input Waiting for input from the original author labels Feb 23, 2016
@nilsen340
Copy link
Author

@segiddins Sorry, I fixed the homepage issue. If you run pod install now you will get the error from the report

@segiddins segiddins removed the s4:awaiting validation A Pull Request that is waiting for validation by a CocoaPods Core Team member label Feb 23, 2016
@segiddins
Copy link
Member

Yup, just reproduced it, thanks!

@segiddins segiddins added the s2:confirmed Issues that have been confirmed by a CocoaPods contributor label Feb 23, 2016
@segiddins
Copy link
Member

Issue here is the asset catalogue inside of source files. @efirestone how should we handle that case?

@segiddins segiddins added t2:defect These are known bugs. The issue should also contain steps to reproduce. PRs welcome! s3:detailed Issues with in-depth explanations and examples that make it easier to troubleshoot and removed s2:confirmed Issues that have been confirmed by a CocoaPods contributor labels Feb 23, 2016
@efirestone
Copy link
Contributor

IMO this is a configuration error, although we should handle it more gracefully. It's a configuration error because we're saying that a resource is a source file, which it's not. The easy fix here is to change s.source_files = 'Pod/Classes/**/*' to be something like s.source_files = 'Pod/Classes/**/*.{c,h,hh,m,mm}'.

It looks like pre-1.0.0 this would still just blindly copy assets into the sources phase, which would then fail to build. To get to an equivalent behavior with the new resources handling we should add the nil path handling that's currently in the resources build phase code into the sources build phase code as well.

Another alternative, and this is really a bigger feature, is to provide more understanding of different file types and properly put them into their respective groups (headers, sources, resources, etc). In this world it would recognize that even though a .png file was specified in s.source_files, it's actually a resource and should be added to the resources phase and not the compile phase.

  1. @nilsen340 For the time being, I'd suggest fixing your s.source_files definition. It's incorrect as-is and I don't think would compile even if CocoaPods wasn't crashing.
  2. @segiddins I'd suggest going with the first approach (add nil path handling to the build phase). I can try to look into this later today if you agree with going that direction.

@segiddins
Copy link
Member

I'm fine with this failing, just as long as it raises an informative error and encourages running pod lib lint, which should catch this

@segiddins segiddins added the d1:easy An easy ticket that is a good start for first-time contributors label Mar 11, 2016
@appcoders
Copy link

Changing the source_files does not help. I have a private podspec with previously containing

s.source_files = 'SITFinBanks/**/*

I changed this to:

s.source_files = 'SITFinBanks/**/*.{m,h,mm,hpp,cpp,c}'

But still getting the same error on pod spec lint:

-> SITFinBanks (1.4.7)
    - WARN  | source: Git SSH URLs will NOT work for people behind firewalls configured to only allow HTTP, therefore HTTPS is preferred.
    - ERROR | [iOS] unknown: Encountered an unknown error (undefined method `path' for nil:NilClass
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/xcodeproj-1.0.0.beta.3/lib/xcodeproj/project/object/native_target.rb:442:in `block in add_file_references'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/xcodeproj-1.0.0.beta.3/lib/xcodeproj/project/object/native_target.rb:441:in `map'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/xcodeproj-1.0.0.beta.3/lib/xcodeproj/project/object/native_target.rb:441:in `add_file_references'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/installer/target_installer/pod_target_installer.rb:94:in `block in add_files_to_build_phases'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/installer/target_installer/pod_target_installer.rb:75:in `each'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/installer/target_installer/pod_target_installer.rb:75:in `add_files_to_build_phases'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/installer/target_installer/pod_target_installer.rb:21:in `block in install!'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/user_interface.rb:144:in `message'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/installer/target_installer/pod_target_installer.rb:17:in `install!'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/installer.rb:619:in `block (2 levels) in install_libraries'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/installer.rb:617:in `each'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/installer.rb:617:in `block in install_libraries'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/user_interface.rb:144:in `message'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/installer.rb:616:in `install_libraries'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/installer.rb:170:in `block in generate_pods_project'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/user_interface.rb:63:in `section'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/installer.rb:167:in `generate_pods_project'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/validator.rb:433:in `block in install_pod'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/validator.rb:433:in `each'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/validator.rb:433:in `install_pod'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/validator.rb:271:in `block in perform_extensive_analysis'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/validator.rb:263:in `each'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/validator.rb:263:in `perform_extensive_analysis'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/validator.rb:81:in `validate'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/command/spec/lint.rb:60:in `block in run'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/command/spec/lint.rb:50:in `each'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/command/spec/lint.rb:50:in `run'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/claide-1.0.0.beta.3/lib/claide/command.rb:334:in `run'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/lib/cocoapods/command.rb:50:in `run'
/Users/mschicker/.rvm/rubies/ruby-2.1.0/lib/ruby/gems/2.1.0/gems/cocoapods-1.0.0.beta.6/bin/pod:44:in `<top (required)>'
/Users/mschicker/.rvm/gems/ruby-2.1.0/bin/pod:23:in `load'
/Users/mschicker/.rvm/gems/ruby-2.1.0/bin/pod:23:in `<main>'
/Users/mschicker/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `eval'
/Users/mschicker/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `<main>'

@mohemian-92817281
Copy link

I'm having the same issue.

@cgossain
Copy link

efirestone's answer on Feb 23 fixed the issue for me. I was pulling in a bunch of file that were not source files.

@cuddergambino
Copy link

cuddergambino commented Sep 17, 2016

I don't have any assets in my source folder, and I'm getting this issue now.

Stack:

   CocoaPods : 1.1.0.rc.2
        Ruby : ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15]
    RubyGems : 2.4.5.1
        Host : Mac OS X 10.11.6 (15G31)
       Xcode : 8.0 (8A218a)
    Language : Swift 3
         Git : git version 2.8.4 (Apple Git-73)

Podspec

I have no assets, just swift files. The end of my Podspec looks like:

...
s.source_files = "Sources/**/*"
s.public_header_files = "Sources/**/*.h"
end

Podfile

use_frameworks!

target 'DopamineKit_Example' do
    pod 'DopamineKit', :path => '../'

    target 'DopamineKit_Tests' do
        inherit! :search_paths

    end
end

post_install do |installer|
    installer.pods_project.targets.each do |target|
        if target.name == 'DopamineKit'
            target.build_configurations.each do |config|
                if config.name == 'Debug'
                    config.build_settings['OTHER_SWIFT_FLAGS'] = '-DDEBUG'
                end
            end
        end
    end
end

Error

The error I'm getting is the single line:

- ERROR | [iOS] unknown: Encountered an unknown error (undefined method `path' for nil:NilClass) during validation.

@MoinPansare
Copy link

hi faced a similar issue
in order to resolve it I needed to move the .xcassets Folder which was created in Classes folder inside the Pod and add it to Assets Folder
screen shot 2017-05-05 at 11 25 10 am

Hope this helps someone.

@amorde
Copy link
Member

amorde commented Nov 3, 2017

Was this fixed by #6869?

@dnkoutso
Copy link
Contributor

dnkoutso commented Nov 3, 2017

best thing to do is clone the sample project and try it!

@amorde
Copy link
Member

amorde commented Nov 3, 2017

Tried out @nilsen340's project and undid the fix to the Podspec, it now fails with an Unable to find source ref.. error. I think that was the desired behavior 👍

@dnkoutso
Copy link
Contributor

dnkoutso commented Nov 3, 2017

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
d1:easy An easy ticket that is a good start for first-time contributors s3:detailed Issues with in-depth explanations and examples that make it easier to troubleshoot t2:defect These are known bugs. The issue should also contain steps to reproduce. PRs welcome!
Projects
None yet
Development

No branches or pull requests

10 participants