30

how can I specify in podspec a local path for an dependency ?

like : s.dependency 'MyLibrary', :path => '../MyLibrary'

thanks

Danilo
  • 631
  • 1
  • 9
  • 24

2 Answers2

23

You should use the :path keyword in your Podfile :

pod 'AFNetworking', :path => '~/Documents/AFNetworking/AFNetworking.podspec'

Tips: If you don't know the path, you can drag & drop the file in your Podfile and it will display it.

EDIT

I did not understand correctly what the OP was asking for, here is the correct answer:

  1. Put the local dependency inside your pod's folder root directory,
  2. In your Podspec file, just add s.ios.dependency 'YourPodName/YourPodDependencyFolder'

After that, create a subspace like so:

s.subspec 'YourPodName' do |ss|
ss.source_files = 'YourPodName/**/*.{h,m}'
end
Loegic
  • 3,390
  • 20
  • 33
  • I use the second way, but the path of source_files are preceded by the ".. /" – Danilo Sep 30 '15 at 13:01
  • Remove the ../ in that case. If you read correctly, you have to place the source file of the dependency in the root folder of the pod – Loegic Sep 30 '15 at 13:56
  • 1
    what is this `s.ios.dependency 'YourPodName/YourPodDependencyFolder'` meaned by ?. can you elaborate? – Vaisakh KP Feb 04 '19 at 10:39
  • 1
    :local dependency was removed from podspec a long time ago, you need to publish cocoapod to mention it as a depedency in another podspec. – abhinavroy23 Dec 09 '19 at 11:19
  • 1
    What do you mean `YourPodDependencyFolder`? – Hari Honor Nov 19 '20 at 16:53
  • If you cannot, or prefer not to, put the local dependency inside the pod folder's root directory, you can use `s.prepare_command` to run `ln -s` command that will create symlink of the local dependency inside the pod folder. – Alex Cohn Nov 07 '21 at 16:05
2

I can't put the other libraries in the root of my library, these are inside the parent because are shared with other project, but unfortunately without use the pods, and I'm trying to use the pods for all, and I already configured the podspec for all libraries.

I'm trying to do something like this written below, but do not appear to work:

Pod::Spec.new do |s|
    s.name                  = 'MyLibrary'
    s.platform              = 'ios'
    s.ios.deployment_target = '7.1'
    s.source_files          = 'Classes/**/.{h,m}'
    s.resource              = 'Classes/resources/*.*'
    s.requires_arc          = true
    s.dependency 'AFNetworking'
    s.dependency 'SharedLib'

    s.subspec 'SharedLib' do |ss|
        ss.source_files         = '../SharedLib/Classes/**/*.{h,m}'
        s.resource              = '../SharedLib/Classes/resources/*.*'
        ss.ios.framework        = 'AVFoundation'
    end
end

thanks for all.

Dominique
  • 16,450
  • 15
  • 56
  • 112
Danilo
  • 631
  • 1
  • 9
  • 24
  • 1
    @Danilo... how do you set local path in source of the pod spec.. I tried with the below and it installed right files in my project however when I am trying to update in files in pod spec, its not updating in example project!! s.source = { :path => ".", :tag => s.version.to_s } – Saty Apr 04 '16 at 09:43
  • @Saty I don't longer use that system, I use saving the library in svn addr http: //your-ip/lib-name/trunk/1.0.0 and add spec in podfile like this: pod 'lib-name', :svn => "http: //your-ip/lib-name/trunk/1.0.0". – Danilo Apr 04 '16 at 13:14
  • the path you have given here is the path in podfile.. I want to know pod spec file details when you create the cocoapod.... – Saty Apr 05 '16 at 05:56
  • @Saty i use this: s.source = { :svn => 'http: //my-svn-server/MyLib/trunk/1.0.0' } (remove the space after http:) – Danilo Apr 05 '16 at 10:33
  • Im not able to integrate my local framework with pod project. – Vaisakh KP Feb 04 '19 at 11:03