What are the restrictions on Cocoa Framework version numbers?
We distribute the Cocoa framework with regular updates. We will update the version numbers with each version. Apple's documentation seems to suggest that version numbers should be sequentially increasing integers. We distribute the output in several formats, and the frames are only one of them. We would prefer not to support a separate numbering system for our frameworks only.
We really don't need the exact format of the framework version numbers as long as they change every time the product changes and behave correctly, sanely, and as expected. I'm looking for a way to avoid having to run a separate version number counter.
One suggestion is that for product version 12.34.56, we could just remove the dots and say the frame version is 123456 (zero-padded).
- Is there a limit on the type of a number that can be represented (uint? Long?)
- Do you need this number? Could it be a string?
- Do the numbers have to be sequential?
- Is there a standard way to do something about this situation?
a source to share
As I understand it, the reason for this requirement is that you can have macros:
#if FRAMEWORKNAME_VERSION >= 123456
// some stuff
#else
// some other stuff
#endif
The numbers don't have to be sequential, and your suggested scheme is quite reasonable:
#define MAKE_VERSION(MAJOR,MINOR,PATCH) ((MAJOR*10000)+(MINOR*100)+PATCH)
I would also suggest that in addition to defining the version, you also define constants for each version ...
#define FRAMEWORKNAME_VERSION_1_0_0 MAKE_VERSION(1,0,0)
#define FRAMEWORKNAME_VERSION_1_0_1 MAKE_VERSION(1,0,1)
So there are several ways you can check ... either:
#if FRAMEWORKNAME_VERSION >= MAKE_VERSION(1,0,1)
// 1.0.1 and later
#else
// Before 1.0.1
#endif
Or:
#if defined(FRAMEWORKNAME_VERSION_1_0_1)
// 1.0.1 and later
#else
// Before 1.0.1
#endif
The key requirements that you must fulfill are:
- The numbers grow monotonously
- Numbers are predictable
- The numbers are easily comparable
If you want to provide a string representation of your version in addition to the integer representation, be sure to do so; however, I would highly recommend that you have an integer representation as it makes comparison easier and allows you to check the version in the preprocessor.
a source to share