Skip to content

Crash when using local podspec with no source #891

Closed
percysnoodle opened this Issue Mar 21, 2013 · 2 comments

2 participants

@percysnoodle

I'm not sure whether this is my first Cocoapods issue or not, but I'll start by saying: Cocoapods is awesome. Thank you so much!

Report

I use AFNetworking and some of our servers have self-signed SSL certificates, so I need to add a #define to my pod headers. I do this using a local pod spec like so:

Pod::Spec.new do |s|

  s.name = 'AllowInvalidSSLCertificates'
  s.version = '0.0.' << Time.now.to_i.to_s
  s.prefix_header_contents = "#define _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_ 1\n"

end

This works fine in 0.16.4. I tried upgrading to 0.17.0rc5 and an exception was thrown, details given below. Are podspecs without source no longer supported? If so, how do I add the #define in 0.17?

Stack

   CocoaPods : 0.17.0.rc5
        Ruby : ruby 1.9.2p320 (2012-04-20 revision 35421) [x86_64-darwin12.2.0]
    RubyGems : 1.8.24
        Host : Mac OS X 10.8.3 (12D78)
       Xcode : 4.6.1 (4H512)
Ruby lib dir : /Users/simonb/.rvm/rubies/ruby-1.9.2-p320/lib
Repositories : master - git@github.com:CocoaPods/Specs.git @ e781ec5f74e6f02989b911a0ebba8026ec857f07

Podfile

platform :ios, '5.0'

pod 'UISS', "~> 1.0"
pod 'MBProgressHUD', '~> 0.5'
pod 'ltools', '~> 2.0.2'
pod 'DTCoreText', '~> 1.3.0'
pod 'BlocksKit', '~> 1.8.1'
pod 'TimesSquare', :git => 'https://github.com/percysnoodle/objc-TimesSquare.git', :commit => '3ecb00c'

restkit_version = '~> 0.20.0pre'

target :main, :exclusive => true do
  link_with 'MyApp'

  pod 'RestKit', restkit_version
  pod 'AllowInvalidSSLCertificates', :podspec => 'AllowInvalidSSLCertificates.podspec'
end

target :test, :exclusive => true do
  link_with 'Functional Tests'

  pod 'RestKit', restkit_version
  pod 'RestKit/Testing', restkit_version
  pod 'KIF', :head
  pod 'OCMock', '~> 2.0'
end

Error

TypeError - can't dup NilClass
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/gems/cocoapods-0.17.0.rc5/lib/cocoapods/installer/pod_source_installer.rb:158:in `dup'
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/gems/cocoapods-0.17.0.rc5/lib/cocoapods/installer/pod_source_installer.rb:158:in `downloader'
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/gems/cocoapods-0.17.0.rc5/lib/cocoapods/installer/pod_source_installer.rb:113:in `download_source'
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/gems/cocoapods-0.17.0.rc5/lib/cocoapods/installer/pod_source_installer.rb:76:in `install!'
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/gems/cocoapods-0.17.0.rc5/lib/cocoapods/installer.rb:249:in `install_source_of_pod'
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/gems/cocoapods-0.17.0.rc5/lib/cocoapods/installer.rb:219:in `block (2 levels) in install_pod_sources'
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/gems/cocoapods-0.17.0.rc5/lib/cocoapods/user_interface.rb:73:in `titled_section'
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/gems/cocoapods-0.17.0.rc5/lib/cocoapods/installer.rb:218:in `block in install_pod_sources'
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/gems/cocoapods-0.17.0.rc5/lib/cocoapods/installer.rb:216:in `each'
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/gems/cocoapods-0.17.0.rc5/lib/cocoapods/installer.rb:216:in `install_pod_sources'
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/gems/cocoapods-0.17.0.rc5/lib/cocoapods/installer.rb:101:in `block in download_dependencies'
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/gems/cocoapods-0.17.0.rc5/lib/cocoapods/user_interface.rb:52:in `section'
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/gems/cocoapods-0.17.0.rc5/lib/cocoapods/installer.rb:99:in `download_dependencies'
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/gems/cocoapods-0.17.0.rc5/lib/cocoapods/installer.rb:85:in `install!'
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/gems/cocoapods-0.17.0.rc5/lib/cocoapods/command/project.rb:40:in `run_install_with_update'
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/gems/cocoapods-0.17.0.rc5/lib/cocoapods/command/project.rb:70:in `run'
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/gems/claide-0.2.0/lib/claide.rb:535:in `run'
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/gems/cocoapods-0.17.0.rc5/lib/cocoapods/command.rb:36:in `run'
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/gems/cocoapods-0.17.0.rc5/bin/pod:16:in `<top (required)>'
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/bin/pod:19:in `load'
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/bin/pod:19:in `<main>'
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/bin/ruby_noexec_wrapper:14:in `eval'
/Users/simonb/.rvm/gems/ruby-1.9.2-p320/bin/ruby_noexec_wrapper:14:in `<main>'
@alloy
CocoaPods member
alloy commented Mar 21, 2013

I'm not sure whether this is my first Cocoapods issue or not, but I'll start by saying: Cocoapods is awesome. Thank you so much!

From all of us, thanks so much for that! ❤️

Regarding the error, this is because you have not defined a ‘source’, which it tries to copy. Which makes sense, because you don’t actually have a source.

You‘re approach is interesting and we might include the idea in one of our many considerations around the topic of prefix headers, but for now I think it’s a better workaround if you use the post_install hook to append to the prefix header. Or am I overlooking something?

@percysnoodle

Sounds good to me. I've added this:

post_install do |rep|
    rep.project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ''
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] <<= " _AFNETWORKING_ALLOW_INVALID_SSL_CERTIFICATES_=1"
      end
    end
  end

It seems to have added the definition once in Release and twice in Debug, but as it works I'm not too worried about that. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.