I have a public fork of a library that already exists in CocoaPods/Specs. In a Podfile, I can reference this forked pod by doing this:
pod 'CoolLibrary', :git => '[email protected]:myname/CoolLibrary-Forked.git', :commit => 'abcdef1234567890abcdef1234567890'
I tried putting this in my MyLibrary.podspec
:
s.dependency 'CoolLibrary', :git => '[email protected]:myname/CoolLibrary-Forked.git', :commit => 'abcdef1234567890abcdef1234567890'
But get the following error message:
-> MyLibrary.podspec - ERROR | The specification defined in `MyLibrary.podspec` could not be loaded. [!] Invalid `MyLibrary.podspec` file: [!] Unsupported version requirements. Updating CocoaPods might fix the issue.
Is it possible to specify a dependency in a .podspec in this way (i.e. for a pod that has a podspec, but which isn't in CocoaPods/Specs)?
After you have initially installed CocoaPods into your project, you can add new dependencies (or remove unused ones) by editing the Podfile. Then simply run pod install again.
A specification describes a version of Pod library. It includes details about where the source should be fetched from, what files to use, the build settings to apply, and other general metadata such as its name, version, and description. A stub specification file can be generated by the pod spec create command.
Podfile. lock is used to make sure that every members of the team has the same versions of pods installed on the project. This file is generated after you run the command: pod install. It gets updated when you run pod install or pod update.
The beauty of CocoaPods is that you list the dependencies of your project in a central location, the project's Podfile. CocoaPods refers to a dependency as a pod hence the name Podfile. Because CocoaPods took inspiration from Bundler, the syntax and format look similar to that of a Gemfile.
Updating dependencies with CocoaPods requires two steps: Update the project's Podfile by removing CocoaLumberjack from the Podfile and lowering the version of Alamofire. Open Terminal or iTerm and run pod update to update the project's dependencies.
You would define pod 'C', :git => "blah", :branch => "x" somewhere in the podfile, and then when your Podspec searches for it's dependency it finds it from given podfile ( with the different branch )
The RubyGems version specifiers describes exactly how to use the comparison operators that specify dependency versions. Following the pattern established in RubyGems, pre-release versions can also be specified in CocoaPods. A pre-release of version 1.2, for example, can be specified by 1.2-beta3.
This is not allowed from podspecs, because allowing so would make it next to impossible for other podspecs to define what package they depend on and/or other packages could break because of unexpected API differences.
For instance, consider two pods that depend on AFNetworking, but one specifies an external source location (Pod A) while the other only specifies a minimum version requirement (Pod B):
s.dependency 'AFNetworking', :git => 'https://arbitrary/location'
s.dependency 'AFNetworking', '> 2'
Now there are a couple of potential problems:
I hope this makes it clear why we cannot introduce a way for podspecs to silently break the version promises. However, from your Podfile you are allowed to override any pod’s source location, because it is the end-user (the app developer) who is in control and there should not be any unexpected breakage.
Dependencies are very simple, having only the ability to define the name and the version specifier of an Pod. They cannot be extended with the same extensions as a dependency in the Podfile.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With