为何Codename One禁止含两个点的版本字符串?Android、iOS均支持该格式
Great question! Let's break down exactly why Codename One restricts version strings from using two dots (like 1.2.3), even though modern Android and iOS fully support this format:
Legacy Platform Compatibility Roots: Codename One was built to support a much wider range of platforms beyond just Android and iOS—think older systems like J2ME, which had strict rules around version string formatting. The core build system was designed to work reliably across all these targets, and allowing multi-dot versions would break compatibility with those legacy environments. Even though many of those platforms are less common now, the restriction stuck to maintain backward consistency in the tooling.
Cloud Build Pipeline Parsing Ambiguity: Codename One uses a cloud-based build system that automatically maps your app's version string to platform-specific fields. For example:
- On iOS, it splits versions into
CFBundleShortVersionString(the user-facing display version) andCFBundleVersion(the internal build number) - On Android, it maps to
versionNameandversionCode
A two-dot version like
1.2.3creates ambiguity here—does the third segment map to the build number, or is it part of the display version? The Codename One team chose to avoid this confusion entirely by enforcing a simpler format.- On iOS, it splits versions into
Enforced Simplified Versioning: The team intentionally pushed for a more straightforward versioning strategy for cross-platform apps. By limiting versions to formats like
x.yor a single integer, they reduce the chance of developers running into platform-specific edge cases or inconsistent version display across devices.
Workarounds for Representing Patch Versions
If you need to track patch releases, here are a few solid options:
- Combine Patch into Minor Version: Use a single minor version number that incorporates the patch, e.g.,
1.23instead of1.2.3(where23means minor version 2, patch 3). - Suffix for Patches: Append a patch identifier as a suffix if your target platforms allow it, like
1.2-patch3(just make sure to test this across all platforms you support). - Leverage Build Numbers: Keep your display version as
x.y, but use the separate build number field to track individual patches. Each patch release gets an incremented build number, while the user-facing version stays consistent until a minor/major update.
内容的提问来源于stack exchange,提问作者Osman

