I am trying to figure how I can declare a subspec dependency from B to A when subspec B is depend on subspec A in the podspec file as below.
Pod::Spec.new do |s|
s.name = "MyLib-SDK"
s.version = "1.0"
s.summary = "My Library"
s.homepage = "http://myhomepage.com"
s.ios.deployment_target = "8.0"
s.ios.frameworks = "Foundation", "UIKit", "SystemConfiguration", "Security", "CoreTelephony", "WebKit"
s.source = { :git => "https://github.com/myhome/ios-project.git", :tag => "1.0" }
s.subspec 'MyLibrary-A' do |libOne|
libOne.source_files = "Headers", "Headers/**/*.h"
libOne.exclude_files = "Headers/Exclude"
libOne.resources = "SharedAssets/*"
libOne.libraries = "z","sqlite3" #Zlib for gzip, sqlite3 for event store
libOne.vendored_library = "libMyLibrary_A.a"
end
s.subspec 'MyLibrary-B' do |libTwo|
libTwo.source_files = "Headers", "Headers/**/*.h"
libTwo.exclude_files = "Headers/Exclude"
libTwo.resources = "SharedAssets/*"
libTwo.dependency 'MyLibrary-A'
libTwo.libraries = "sqlite3" # sqlite3 for db
libTwo.vendored_library = "libMyLibrary_B.a"
end
end
ℹ pod spec lint <mybodspecfile> --verbose
ℹ validation passed
ℹ - ERROR | [iOS] unknown: Encountered an unknown error (Unable to find a specification for MyLibrary-A depended upon by MyLibrary-B
+1
In my case Lib-A and Lib-B are 2 different targets. So Lib-B has import Lib-A throughout. And a user of the repo should be able to use both modules e.g. import Lib-A and import Lib-B where required.
Hey there, this looks like a great example of a question that you should ask on StackOverflow - there is an active tag CocoaPods where people can help out with questions like this. We try to keep the CocoaPods issues focused only on bug reports for the tool, and for upcoming feature requests. Which this doesn't look like.
Sounds like you know the solution then if it's not a bug, could you provide it?
@orta could a bug include a lack of documentation for a feature?
@rex-remind101 @orta This question is actual related to bug reported at: https://github.com/CocoaPods/CocoaPods/issues/6309
Since someone suggested to go around this problem by declaring dependency on the subspec to avoid duplicated symbol problem.
Generally, you just do s.dependency = <podname>. Subspecs are identified by name like so:
@benasher44 Yes, that appears to resolve dependency issue within the podspec although I still have other problem to resolve which is not related to this post. Thank you so much!!
Most helpful comment
Generally, you just do/. AFNetworking does this. Have a look at their spec as an example: https://github.com/AFNetworking/AFNetworking/blob/master/AFNetworking.podspec
s.dependency = <podname>. Subspecs are identified by name like so: