Specifying a podspec which contains subspecs throws exception #141

jdzak opened this Issue Feb 27, 2012 · 10 comments


None yet
4 participants

jdzak commented Feb 27, 2012

In the Podfile, when specifying a podspec which contains subspecs an exception is thrown.

# Podfile

platform :ios

dependency 'RestKit/Network', :podspec =>  "RestKit-Custom-0.9.3.podspec"
# RestKit-Custom-0.9.3.podspec

Pod::Spec.new do |s|
  s.name = 'RestKit'
  s.version = '0.9.3'
  s.summary = 'RestKit is a framework for consuming and modeling RESTful web resources on iOS and OS X.'
  s.homepage = 'http://www.restkit.org'
  s.author = { 'Blake Watters' => 'blakewatters@gmail.com' }
  s.source = { :git => 'https://github.com/RestKit/RestKit.git', :tag => '0.9.3' }

  # It has no source_files itself, so the resolver should not allow dependencies on this spec unless it’s a `part_of' type dependency

  def s.copy_header_mapping(from)

  # This creates a new Pod::Specification instance, which has the the following attributes:
  # * part_of: 'RestKit', '0.9.3'
  # * name: 'RestKit/Network'
  # Other attributes are delegated to the `part_of' spec, so the version, summary etc will by default be the same
  s.subspec 'Network' do |ns|
    ns.description = 'The network layer provides a request/response abstraction on top of NSURLConnection.'
    ns.dependency 'LibComponentLogging-NSLog'
    ns.source_files = 'Code/RestKit.h', 'Code/{Network,Support}/*.{h,m}'
    if config.ios?
        ns.frameworks = 'CFNetwork', 'Security', 'MobileCoreServices', 'SystemConfiguration'
        ns.frameworks = 'CoreServices', 'Security', 'SystemConfiguration'

  # Like before, this creates a new spec with the name: RestKit/ObjectMapping and is a part of RestKit
  s.subspec 'ObjectMapping' do |os|
    os.description = %{The object mapping layer provides a simple API for turning remote JSON/XML responses into objects.}
    os.dependency 'RestKit/Network'
    os.source_files = 'Code/ObjectMapping/*.{h,m}'

    # This spec will have the name: RestKit/ObjectMapping/JSON.
    # Since it’s nested under another sub spec, it automatically depends on the parent: RestKit/ObjectMapping
    os.subspec 'JSONKit' do |jos|
      jos.description = 'The RestKit JSON parser which wraps JSONKit.'
      jos.source_files = 'Code/Support/Parsers/JSON/RKJSONParserJSONKit.{h,m}'
      jos.dependency 'JSONKit'

    # This spec will have the name: RestKit/ObjectMapping/XML.
    # Since it’s nested under another sub spec, it automatically depends on the parent: RestKit/ObjectMapping
    os.subspec 'XML' do |xos|
      xos.description = 'The RestKit XML parser which wraps libxml2.'
      xos.source_files = 'Code/Support/Parsers/XML/RKXMLParserLibXML.{h,m}'
      xos.library = 'xml2'
      xos.xcconfig = { 'HEADER_SEARCH_PATHS' => '$(SDKROOT)/usr/include/libxml2' }
  s.subspec 'CoreData' do |ds|
      ds.description = %{The Core Data layer provides additional support on top of the object mapper for mapping from remote resources to persist local objects.}
      ds.source_files = 'Code/CoreData/*.{h,m}'
      ds.frameworks = 'CoreData'

      #if we copy headers to default location
      ##import  will use RestKit header instead of
      def ds.copy_header_mapping(from)
ncs$ b pod install --verbose
Updating spec repo `master'
/usr/local/bin/git pull
Already up-to-date.
Installing dependencies of: /Users/jd/Code/ncs/Podfile
Depdendency: RestKit/Network (from `RestKit-Custom-0.9.3.podspec')
  * Fetching podspec for `RestKit/Network' from: RestKit-Custom-0.9.3.podspec
No podspec exists at path `/Users/jd/Code/ncs/Pods/RestKit/Network.podspec'.
/Users/jd/.rvm/gems/ree-1.8.7-2011.03@ncs/gems/cocoapods-0.5.1/lib/cocoapods/specification.rb:14:in `from_file'
/Users/jd/.rvm/gems/ree-1.8.7-2011.03@ncs/gems/cocoapods-0.5.1/lib/cocoapods/dependency.rb:97:in `specification'
/Users/jd/.rvm/gems/ree-1.8.7-2011.03@ncs/gems/cocoapods-0.5.1/lib/cocoapods/resolver.rb:39:in `find_dependency_set'
/Users/jd/.rvm/gems/ree-1.8.7-2011.03@ncs/gems/cocoapods-0.5.1/lib/cocoapods/resolver.rb:16:in `find_dependency_sets'
/Users/jd/.rvm/gems/ree-1.8.7-2011.03@ncs/gems/cocoapods-0.5.1/lib/cocoapods/resolver.rb:14:in `each'
/Users/jd/.rvm/gems/ree-1.8.7-2011.03@ncs/gems/cocoapods-0.5.1/lib/cocoapods/resolver.rb:14:in `find_dependency_sets'
/Users/jd/.rvm/gems/ree-1.8.7-2011.03@ncs/gems/cocoapods-0.5.1/lib/cocoapods/resolver.rb:9:in `resolve'
/Users/jd/.rvm/gems/ree-1.8.7-2011.03@ncs/gems/cocoapods-0.5.1/lib/cocoapods/installer.rb:7:in `dependent_specifications'
/Users/jd/.rvm/gems/ree-1.8.7-2011.03@ncs/gems/cocoapods-0.5.1/lib/cocoapods/installer.rb:11:in `build_specifications'
/Users/jd/.rvm/gems/ree-1.8.7-2011.03@ncs/gems/cocoapods-0.5.1/lib/cocoapods/installer.rb:57:in `install_dependencies!'
/Users/jd/.rvm/gems/ree-1.8.7-2011.03@ncs/gems/cocoapods-0.5.1/lib/cocoapods/installer.rb:75:in `install!'
/Users/jd/.rvm/gems/ree-1.8.7-2011.03@ncs/gems/cocoapods-0.5.1/lib/cocoapods/command/install.rb:44:in `run'
/Users/jd/.rvm/gems/ree-1.8.7-2011.03@ncs/gems/cocoapods-0.5.1/lib/cocoapods/command.rb:53:in `run'
/Users/jd/.rvm/gems/ree-1.8.7-2011.03@ncs/bin/pod:19:in `load'

jdzak commented Feb 27, 2012

It looks like it fails because it tries to copy the podspec to the Restkit/Network directory , which doesn't exist yet.


alloy commented Feb 27, 2012

What happens is that in the case of using :podspec, it naively assumes that the spec is simply the Pod dir plus its name, which is incorrect in the case of a subspec. I think there might be more going on too, but haven't investigated yet.

I've frustrated on Restkit subspec, both HEAD and Released version doesn't work.

@jdzak I use a temporary solution which is build an static library for Restkit from source code myself.

@alloy I saw there are big difference between HEAD and Released version. Which branch we should work on if we want to fix this problem? probably master?


alloy commented Mar 30, 2012

@allenwei What doesn’t work with the spec of the released (0.9.3) version? I have been working on a spec for the upcoming 0.9.4 release in the RestKit branch. I need to do some cleaning, but it should work.

@alloy The problem is cocoapods it self, it is not handle sub spec correctly like @jdzak said

jdzak commented Mar 30, 2012

@allenwei If you use the RestKit podspec from the main repository[1], Restkit
should work for you. The 0.9.3 podspec is currently working for me.

The bug for this ticket I found when trying to use a custom RestKit podspec I had saved in
my project directory.



dependency 'RestKit/Network', '0.9.3'
dependency 'RestKit/ObjectMapping', '0.9.3'
dependency 'RestKit/ObjectMapping/CoreData', '0.9.3'
dependency 'RestKit/ObjectMapping/JSONKit', '0.9.3'

On Fri, Mar 30, 2012 at 10:35 AM, allenwei <


@alloy The problem is cocoapods it self, it is not handle sub spec
correctly like @jdzak said

Reply to this email directly or view it on GitHub:
#141 (comment)

@jdzak you are right. 0.9.3 works.
The problem is the way CocoaPods handle custom spec which have subspec is not correct. I'll dig into it.


alloy commented Mar 30, 2012

@allenwei Aah, right, sorry. Originally this ticket wasn’t about RestKit, but about sub specs in an ‘inline’ spec. Cool, thanks!


jeanregisser commented Apr 24, 2012

There's a similar issue if you try something like this:
dependency 'RestKit/Network', :git => 'git://example.com/my_restkit_fork.git'

Where my_restkit_fork is a repository containing a RestKit.podspec at its root.


alloy commented May 12, 2012

This is fixed by @jeanregisser’s patch (#255).

@alloy alloy closed this May 12, 2012

jzapater pushed a commit to jzapater/CocoaPods that referenced this issue Sep 17, 2013

jeanregisser added a commit that referenced this issue Oct 25, 2014

fabiopelosin added a commit that referenced this issue Oct 25, 2014

Merge branch 'master' into spec-refactor
* master:
  Minor copy change
  A few small fixes related to integrating multiple targets/projects.
  Add rake ~> 0.9.0 (for rake/file_list.rb file) to gemspec. Closes #195.
  Fix for #141
  [Push] Bypass pre-commit hook.
  [Fix] GitHub downloader was downloading the repos twice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment