Update Podfile Guide to clarify version operator usage #1793

Closed
coreyfloyd opened this Issue Feb 5, 2014 · 4 comments

Projects

None yet

2 participants

@coreyfloyd

I recently had an issue here:
#1792

The fix was that I was using a version operator incorrectly. The docs do state this, however it never stuck out to me:

~> 0.1.2 Version 0.1.2 and the versions up to 0.2, not including 0.2

(from: http://guides.cocoapods.org/syntax/podfile.html#pod)

I definitely glanced over this definition and interpreted '~>' to mean "up to and including", however it means ">= but less than the next major version".

It is just very easy to read over.

I would suggest updating the docs to something more like @alloy's answer in the comments below:

~> 0.1.2 Any version >= 0.1.2 and < 0.2 (The next major version)

I think the >= and < operators stick out much better than just the plain text.

(Thanks to everyone for their help!)

@alloy
Member
alloy commented Feb 5, 2014

Whether or not your version is using Semantic Versioning is actually not relevant. That @Keithbsmiley mentioned it was a red herring. I also agree that the guide skips over this too easily.

The real explanation of the operator is more like: “This operator works based on the last component that you specify in your version requirement.”.

So ~> 0.1.2 is equal to >= 0.1.2 combined with < 0.2.0. Likewise, this non-SemVer version ~> 3.184 is equal to >= 3.184 combined with < 4.0, which matches the version that you were getting: 3.196, as CocoaPods will always try to install the latest known version matching your requirements.

In case this is now clear to you, would you mind writing up a better explanation, if you have ideas for improvement? Then I will apply the change to the location where this doc is generated from.

@coreyfloyd

@alloy thanks for the clarification. I read that more than a few times (over the past year!) and still missed it. I think your explanation is much more clear. I will update my ticket accordingly. Thanks again.

@coreyfloyd

@alloy let me know if my update is sufficient, thanks again.

@alloy alloy added a commit to CocoaPods/Core that closed this issue Feb 5, 2014
@alloy alloy [Podfile] Clarify ~> operator. b191d9e
@alloy
Member
alloy commented Feb 5, 2014

Thanks for the feedback!

@Ashton-W Ashton-W pushed a commit to Ashton-W/Core that referenced this issue Nov 2, 2015
@alloy alloy [Podfile] Clarify ~> operator. 709f7d8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment