Is it possible to add a local dependency to .podspec file?

生来就可爱ヽ(ⅴ<●) 提交于 2020-07-04 06:58:32

问题


I'm using cocoapods now I would like to add a local pod dependency in my project, something like:

s.dependency = 'my pod', :path => ''

but I think is not possibile, some ideas?


回答1:


I have faced with the same issue and after lot of googling and asking on the CocoaPods github I have finally found the suitable answer.

It's not possible to set a local pod as a dependency, but it's possible to set a pod's source for a specific Podfile, which will work the same way.

E.g., in your podspec, you still have ()

s.dependency = 'my pod', '~> 1.0' # or whatever version you have

Then in your Example/demo/test project's Podfile:

pod 'my pod', :path => '/path/to/the/local/my_pod'

Then just run pod install and you will see both pods as a Development pods.

This way is very useful when you're developing 2 pods (one of which is dependend on the other) simultaneously, yet for release you will still have to publish your pod to the repo (either CocoaPods or a private repo).




回答2:


You can use pod with a path

pod 'PodName', :path => 'local_path_to/name.podspec'

The full chain you can find here




回答3:


Put the local dependency inside your pod's folder root directory, In your Podspec file, just add s.ios.dependency 'YourRootPodName/YourPodDependencyFolder' After that, create a subspace like so:

s.subspec 'YourRootPodName' do |ss| ss.source_files = 'YourRootPodName/**/*.{h,m}' end

as in this answer Cocoa podspec and path for dependency



来源:https://stackoverflow.com/questions/46052798/is-it-possible-to-add-a-local-dependency-to-podspec-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!