Cocoapods: Including subspec includes dependency from other subspec

Created on 11 May 2016  路  1Comment  路  Source: CocoaPods/CocoaPods

What did you do?

I have a private pod with two subspecs. One of those subspace's has a dependency on another pod. The other has no dependencies.

What did you expected to happen?

Only the subspec in my Podfile would be installed.

What happened instead?

Only the source files for the subspec that I listed in my Podfile聽were installed, but another pod that was a dependency of the unincluded subspec was also installed into my project.

Podspec

Pod::Spec.new do |s|
  s.platform     = :ios
  s.ios.deployment_target = '8.0'
  s.name         = "MyPrivatePod"
  s.version      = "2.4.6"
  s.summary      = "Private Pod With 2 Subspecs"
  s.source       = { :git => "https://bitbucket.org/AnthonyMDev/myprivatepod.git",
                     :tag => "#{s.version}"}
  s.module_name  = 'MyPrivatePod'
  s.requires_arc = true

  s.subspec 'Core' do |ss|
    s.source_files = "MyPrivatePod/*.{swift,h,m}"

    s.resource_bundles = {
        'MyPrivatePod' => 'MyPrivatePod/Resources/*.png'
    }

    s.dependency 'Alamofire', '~> 3.0'
  end

  s.subspec 'SubspecWithNoDependencies' do |ss|
    ss.source_files = "MyPrivatePod/Subspec/*.{swift,h,m}"

    ss.resource_bundles = {
        'MyPrivatePodSubspec' => 'MyPrivatePod/Subspec/Resources/*.xib'
    }
  end

end

Podfile

platform :ios, '9.0'

source 'https://bitbucket.org/AnthonyMDev/private-spec-repo.git'
source 'https://github.com/CocoaPods/Specs.git'

use_frameworks!
inhibit_all_warnings!

pod "MyPrivatePod/SubspecWithNoDependencies", :path => "../../MyPrivatePod"

target 'MyProject' do

end

target 'MyProject_Tests' do  
  pod 'Nimble', '~> 4.0'
end

Most helpful comment

Immediately after posting this, I realized that in my Core subspec I was declaring my dependencies with s.dependency rather than ss.dependency. Changing that fixed the problem. Sorry!

>All comments

Immediately after posting this, I realized that in my Core subspec I was declaring my dependencies with s.dependency rather than ss.dependency. Changing that fixed the problem. Sorry!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sonu5 picture sonu5  路  3Comments

tlandsmancars picture tlandsmancars  路  3Comments

evermeer picture evermeer  路  3Comments

spencerkohan picture spencerkohan  路  3Comments

pronebird picture pronebird  路  3Comments