Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the usage of "~>" in cocoapods

I want to know what the "~>" is used for,cause I find they are the same below:

pod 'AFNetworking','~> 2.0.3'

pod 'AFNetworking','2.0.3'
like image 919
Mil0R3 Avatar asked Nov 26 '13 09:11

Mil0R3


People also ask

What is Podfile and Podfile lock?

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.

What is a Podfile in Xcode?

The Podfile is a specification that describes the dependencies of the targets of one or more Xcode projects. The file should simply be named Podfile . All the examples in the guides are based on CocoaPods version 1.0 and onwards.

What is Ruby gem CocoaPods?

0. CocoaPods manages library dependencies for your Xcode project. You specify the dependencies for your project in one easy text file. CocoaPods resolves dependencies between libraries, fetches source code for the dependencies, and creates and maintains an Xcode workspace to build your project.


3 Answers

~> (the optimistic operator) is used when you want to specify a version 'up to next major | minor | patch'. For example:

~> 0.1.2 will get you a version up to 0.2 (but not including 0.2 and higher)

~> 0.1 will get you a version up to 1.0 (but not including 1.0 and higher)

~> 0 will get you a version of 0 and higher (same as if it was omitted)

where 0.1.2 would mean 'I want this exact version'

Here is some more info on this

like image 184
Alladinian Avatar answered Oct 16 '22 18:10

Alladinian


  • ~> 6.0 will get you the latest version before the next version which is 7.0 but not including the 7.0 version.

  • ~> 6.0.0 will get you the latest version before the next version which is 6.1.0 but not including the 6.1.0 version.

🎉

like image 30
Abo3atef Avatar answered Oct 16 '22 18:10

Abo3atef


optimistic operator ~>:

'~> 0.1.2' Version 0.1.2 and the versions up to 0.2, not including 0.2 and higher
'~> 0.1' Version 0.1 and the versions up to 1.0, not including 1.0 and higher
'~> 0' Version 0 and higher, this is basically the same as not having it.
For more information, regarding versioning policy, [see][1]:
like image 4
Adnan Aftab Avatar answered Oct 16 '22 18:10

Adnan Aftab