How versions are compared?

Asked by goto

It's not documented and Apple is vague on this. How versions are compared exactly?

Is 1.2.3.0 higher than 1.2.3? 1.3?

Can I update 1.0 to 1.0.0? or 1.0.1 and then 1.1?

Question information

Language:
English Edit question
Status:
Answered
For:
Sparkle Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
goto (gotolaunchpad) said :
#1

Is there standard method/custom for marking alpha and beta versions?

Revision history for this message
Andy Matuschak (andymatuschak) said :
#2

It uses Apple's standard versions, which is three points. The nice way to implement beta versions is 1.2.1 vs 1.2.2 vs 1.2.3, with display version strings like "1.2b1", "1.2b2", "1.2b3", but if you use "1.2b1" it will probably work.

Revision history for this message
Hofman (cmhofman) said :
#3

Often zeros are equivalent to nothing, but that's not guaranteed. You just never should count on it, so never use it (that is, don't use both). As for alphabetic characters, they're not allowed in CFBundleVersion (which is what's used for comparisons), so results are simply undefined (this is documented by Apple, though with some documentation bugs). Apple's docs clearly state that CFBundleVersion can only contain digits and periods, and for those the ordering should be obvious.

The preferred way actually is to use a separate CFBundleVersion that monotonically increases (often simply an integer, as in Apple Generic Versioning) and a human readable CFBundleShortVersionString that can be anything (IMHO here the docs are wrong, bug filed), including strings containing "a" or "b". The former is used for (unambiguous) comparisons, the latter for display (I'm pretty sure about that).

Can you help with this problem?

Provide an answer of your own, or ask goto for more information if necessary.

To post a message you must log in.