ios 我应该为 CFBundleVersion 和 CFBundleShortVersionString 使用什么值?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19726988/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What values should I use for CFBundleVersion and CFBundleShortVersionString?
提问by Bbx
This is my first iOS app submission and I don't want my app rejected.
这是我第一次提交 iOS 应用程序,我不希望我的应用程序被拒绝。
This is from the Apple Docs:
这是来自苹果文档:
CFBundleVersion(String - iOS, OS X) specifies the build version number of the bundle, which identifies an iteration (released or unreleased) of the bundle. The build version number should be a string comprised of three non-negative, period-separated integers with the first integer being greater than zero. The string should only contain numeric (0-9) and period (.) characters. Leading zeros are truncated from each integer and will be ignored (that is, 1.02.3 is equivalent to 1.2.3). This key is not localizable.
CFBundleVersion(String - iOS, OS X) 指定包的构建版本号,它标识包的迭代(已发布或未发布)。构建版本号应该是一个字符串,由三个非负的、以句点分隔的整数组成,第一个整数大于零。该字符串应仅包含数字 (0-9) 和句点 (.) 字符。从每个整数中截断前导零并将被忽略(即,1.02.3 等效于 1.2.3)。此键不可本地化。
CFBundleShortVersionString(String - iOS, OS X) specifies the release version number of the bundle, which identifies a released iteration of the app. The release version number is a string comprised of three period-separated integers. The first integer represents major revisions to the app, such as revisions that implement new features or major changes. The second integer denotes revisions that implement less prominent features. The third integer represents maintenance releases.
CFBundleShortVersionString(String - iOS, OS X) 指定包的发布版本号,它标识应用程序的发布迭代。发布版本号是一个由三个以句点分隔的整数组成的字符串。第一个整数表示对应用程序的主要修订,例如实现新功能或主要更改的修订。第二个整数表示实现不太突出的功能的修订版。第三个整数表示维护版本。
The value for this key differs from the value for “CFBundleVersion,” which identifies an iteration (released or unreleased) of the app. This key can be localized by including it in your InfoPlist.strings files.
此键的值不同于“CFBundleVersion”的值,后者标识应用程序的迭代(已发布或未发布)。可以通过将其包含在您的 InfoPlist.strings 文件中来本地化此密钥。
But it seems a bit strange. My interpretation for this is to put both values the same, i.e.:
不过好像有点奇怪。我对此的解释是将两个值相同,即:
CFBundleVersion: 1.0.0
CFBundleShortVersionString: 1.0.0
Can someone confirm 100% that is what I am supposed to put?
有人可以确认 100% 这是我应该放的吗?
采纳答案by rmaddy
Think of it this way: The "short version" (CFBundleShortVersionString
) is the public version number. The "version" (CFBundleVersion
) is more of an internal version number that could change far more frequently than the public "short version". Personally I use the same for both but many people update the "version" on every build. Either way you typically update the "short version" when you release to Apple. How often you update the "version" is up to you and your needs.
可以这样想:“短版” ( CFBundleShortVersionString
) 是公共版本号。“版本” ( CFBundleVersion
) 更像是一个内部版本号,与公共“简短版本”相比,它的更改频率可能更高。就我个人而言,我对两者都使用相同的方法,但很多人在每次构建时都会更新“版本”。无论哪种方式,您通常都会在向 Apple 发布时更新“简短版本”。您更新“版本”的频率取决于您和您的需要。
回答by Yunus Nedim Mehel
CFBundleShortVersionStringgives you the versionof your app. It's typically incremented each time you publish your app to the App Store. This is the version that is visible on the "Version" section for the App Store page of your application.
CFBundleShortVersionString为您提供应用程序的版本。每次您将应用程序发布到 App Store 时,它通常都会增加。这是在您的应用程序的 App Store 页面的“版本”部分中可见的版本。
CFBundleVersiongives you the build numberwhich is used for development and testing, namely "technical" purposes. The end user is rarely interested in the build number but during the development you may need to know what's being developed and fixed on each build. This is typically incremented on each iteration of internal release. And you can use continuous integration tools like Jenkins to auto-increment the build number on each build.
CFBundleVersion为您提供用于开发和测试的内部版本号,即“技术”目的。最终用户很少对内部版本号感兴趣,但在开发过程中,您可能需要了解每个版本正在开发和修复的内容。这通常在内部发布的每次迭代中增加。您可以使用持续集成工具(如 Jenkins)在每次构建时自动增加构建编号。
The two numbers do not depend on each other but it is a good idea to keep them parallel to avoid confusion. Keep in mind that once your app has passed the App Store review you need to increment the build number like Phil and likeTheSky have stated, regardless of whether you publish it or not.
这两个数字不相互依赖,但最好让它们保持平行以避免混淆。请记住,一旦您的应用通过了 App Store 审核,您就需要像 Phil 和 likeTheSky 所说的那样增加内部版本号,无论您是否发布它。
Use case: Let's say, you have a well-tested build, ready for submission. It's version number is 1.0.0and build number is 1.0.0.32. Once you submit your app, you need to update the version as 1.0.1and build number as 1.0.1.0.
用例:假设您有一个经过良好测试的构建,可以提交。它的版本号是1.0.0,内部版本号是1.0.0.32。提交应用后,您需要将版本更新为1.0.1并将内部版本号更新为1.0.1.0。
回答by Basil Bourque
The answer by rmaddyis correct. I'll add two more thoughts.
Third Version Number
第三版本号
Be aware of the third version number, specified on the iTunesConnect web site as part of your app's definition. If that number is different than the two in Xcode, Apple gives you a warning. You can ignore the warning, as it is not a show-stopper (not an "error").
请注意第三个版本号,它在 iTunesConnect 网站上指定为应用程序定义的一部分。如果该数字与 Xcode 中的两个不同,Apple 会向您发出警告。您可以忽略该警告,因为它不是表演障碍(不是“错误”)。
Date-Time as version
日期时间作为版本
Also, you need not use three numbers with punctuation. That may may sense for some apps, where traditionally changes in the first number indicated some kind of dramatic change usually affecting compatibility.
此外,您不需要使用三个带标点符号的数字。这可能对某些应用程序有意义,其中第一个数字的传统变化表明某种通常会影响兼容性的戏剧性变化。
For other apps you might want to use simply a date-time value in ISO 8601standard format style (YYYYMMDDHHMM). For example, 201606070620
. That order of year-month-date-hour-minute renders an ever-increasing number, always the same length due to padding zero, that when sorted alphabetically is also chronological.
对于其他应用程序,您可能只想使用ISO 8601标准格式样式 (YYYYMMDDHHMM)的日期时间值。例如,201606070620
。年 - 月 - 日 - 时 - 分钟的顺序呈现一个不断增加的数字,由于填充零而始终具有相同的长度,当按字母顺序排序时也是按时间顺序排列的。
I have successfully used this style of version numbers on a shipping iOS app working in iOS 7, 8, & 9.
我已经成功地在 iOS 7、8 和 9 中运行的 iOS 应用程序上使用了这种样式的版本号。
You can even automate the generation of this value. In your project's Target
> Build Phases
> Run Script
panel:
您甚至可以自动生成此值。在您的项目Target
> Build Phases
>Run Script
面板:
- Specify in the
Shell
field:/bin/sh
- Paste the following 5 line script seen below.
- (optional) Check the
Show environment variables in build log
checkbox. - Uncheck the
Run script only when installing
checkbox.
- 在
Shell
字段中指定:/bin/sh
- 粘贴下面看到的以下 5 行脚本。
- (可选)选中
Show environment variables in build log
复选框。 - 取消选中
Run script only when installing
复选框。
Every time you do a build the current date-time in UTCtime zone is captured. The -u
flag in the script makes use of UTC rather than your current default time zone. Generally best for programmers and sysadmins to be using and thinking in UTC rather than local time zones.
每次构建时,都会捕获UTC时区中的当前日期时间。-u
脚本中的标志使用 UTC 而不是您当前的默认时区。通常最适合程序员和系统管理员使用和思考 UTC 而不是本地时区。
#!/bin/bash
buildNumber=$(date -u "+%Y%m%d%H%M")
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $buildNumber" "$INFOPLIST_FILE" # Version number
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE" # Build number
echo "DateTime for app version number: $buildNumber"
Or do a hybrid, with a conventional 1.2.3
for the Version number and a date-time as the Build number. To do the hybrid, simply comment-out the CFBundleShortVersionString
line with a #
in front.
或者做一个混合,用一个常规1.2.3
的版本号和一个日期时间作为内部版本号。要进行混合,只需在前面注释掉该CFBundleShortVersionString
行#
。
回答by plindberg
The scheme most sensible to me is to use the version number (ie. CFBundleShortVersionString
) for the actual version number, and then use the build number (ie. CFBundleVersion
) to represent the submission to the App Store. So unless there are any problems and hence re-submits, this number is always 1. For a new release, I reset to 1 if the previous had issues in TestFlight testing or in review.
对我来说最明智的方案是使用版本号(即CFBundleShortVersionString
)作为实际版本号,然后使用内部版本号(即CFBundleVersion
)来表示提交到 App Store。因此,除非有任何问题并因此重新提交,否则此数字始终为 1。对于新版本,如果前一个在 TestFlight 测试或中存在问题,我将重置为 1。
Build numbers provide a way to name each of the submissions you provide for a particular release. As described in the definitions above, the collection of all of the builds that you provide for a particular version of your app is called that version's 'release train'. For iOS apps, build numbers must be unique within each release train, but they do not need to be unique across different release trains[my emphasis]. That is to say, for iOS Apps you can use the same build numbers again in different release trains if you want to.
内部版本号提供了一种方法来命名您为特定版本提供的每个提交。如上面的定义所述,您为应用程序的特定版本提供的所有构建的集合称为该版本的“发布序列”。对于 iOS 应用程序,内部版本号在每个版本系列中必须是唯一的,但它们在不同版本系列中不需要是唯一的[我的重点]。也就是说,对于 iOS 应用程序,如果您愿意,您可以在不同的版本系列中再次使用相同的内部版本号。
From Technical Note TN2420: Version Numbers and Build Numbers.
回答by Qiulang
I use CFBundleVersionto indicate internal build for CFBundleShortVersionString. I use test flight to submit builds for my testers so the difference between them has been extremely useful.
我用CFBundleVersion来指示内部构建CFBundleShortVersionString。我使用试飞为我的测试人员提交构建,因此它们之间的差异非常有用。
Apple documents says CFBundleVersion "should be a string comprised of 3non-negative, period-separated integers" But actually it can be MORE THAN3 parts(as the above answer shows). I use that to indicate my development build, say my CFBundleShortVersionString is 1.0.0, I can use 1.0.0.11 for CFBundleVersion to indicate that is my 11th build for release 1.0.0
苹果的文件说CFBundleVersion“应该是由一串3非负,期间隔开的整数”但实际上,它可以MORE THAN3个部分(如上面的回答所示)。我用它来表示我的开发版本,比如我的 CFBundleShortVersionString 是 1.0.0,我可以使用 1.0.0.11 作为 CFBundleVersion 来表示这是我发布 1.0.0 的第 11 个版本
Each CFBundleVersion submitted to app store should be bigger than before or you will get ERROR ITMS-90478: "Invalid Version. The build with the version “xxx” can't be imported because a later version has been closed for new build submissions. Choose a different version number."
提交到应用商店的每个 CFBundleVersion 都应该比以前更大,否则您将收到错误 ITMS-90478:“版本无效。无法导入版本为“xxx”的构建,因为更高版本已关闭以供新构建提交。选择不同的版本号。”
CFBundleShortVersionStringcan only have 3 parts or you will get ERROR ITMS-90060:The value for key CFBundleShortVersionString 'xxx' in the Info.plist file must be a period-separated list of at mostthree non-negative integers."
CFBundleShortVersionString只能有 3 个部分,否则您将收到错误 ITMS-90060:Info.plist 文件中的键 CFBundleShortVersionString 'xxx' 的值必须是最多三个非负整数的句点分隔列表。”
The 3rd numberthat Basil Bourque mentioned, i.e. the version number shows on iTunesConnectis where things may get complicated.
Basil Bourque 提到的第三个数字,即iTunesConnect上显示的版本号是事情可能变得复杂的地方。
I use a different iTunesConnect number than CFBundleShortVersionStringbecause when I first submitted my app to app store we already have many rounds of internal releases. So I used 1.0 for iTunesConnect number and 5.x for CFBundleShortVersionString. In the next release to app store I provided a function to check if there is a newer version in the app store and realized I had trouble now because I can only get iTunesConnect number (using http://itunes.apple.com/lookup?bundleId=
) so I need to do some calculation to before compare it with CFBundleShortVersionString number.
我使用与CFBundleShortVersionString不同的 iTunesConnect 编号,因为当我第一次将我的应用程序提交到应用程序商店时,我们已经有很多轮内部版本。所以我使用 1.0 作为 iTunesConnect 号码,使用 5.x 作为 CFBundleShortVersionString。在应用商店的下一个版本中,我提供了一个功能来检查应用商店中是否有更新版本,并意识到我现在遇到了麻烦,因为我只能获得 iTunesConnect 编号(使用http://itunes.apple.com/lookup?bundleId=
),因此我需要在比较之前进行一些计算带有 CFBundleShortVersionString 号。
I tried to fix that by using iTunesConnect number as my CFBundleShortVersionString, but got the error, ERROR ITMS-90062: "This bundle is invalid. The value for key CFBundleShortVersionString [x.x.x] in the Info.plist file must contain a higher version than that of the previously approved version [x.x.x]."
我试图通过使用 iTunesConnect 号码作为我的 CFBundleShortVersionString 来解决这个问题,但得到了错误,ERROR ITMS-90062:“这个包无效。Info.plist文件中的键 CFBundleShortVersionString [xxx] 的值必须包含比那个更高的版本之前批准的版本 [xxx]。”
So I will suggest always make them the same.
所以我建议总是让它们相同。
回答by Dave Evans
Something I've never seen discussed anywhere is what is the maximum number for each field in a CFBundleVersion?
我从未见过在任何地方讨论过的事情是 CFBundleVersion 中每个字段的最大数量是多少?
By setting CFBundleVersion in a app to 1.1.1 and looking at the hexadecimal vaue for the version in "lsregister -dump", I determined that the maximum value for the first field is (2^22)-1 or 4194303, and the maximum values for the second and third fields are (2^21)-1 or 2097151.
通过将应用程序中的 CFBundleVersion 设置为 1.1.1 并查看“lsregister -dump”中版本的十六进制值,我确定第一个字段的最大值为 (2^22)-1 或 4194303,最大值为第二个和第三个字段的值为 (2^21)-1 或 2097151。
The 3 fields add up to 64 bits.
这 3 个字段加起来为 64 位。
This has implications for those of us who use CFBundleVersion based on date and time.
这对我们这些根据日期和时间使用 CFBundleVersion 的人有影响。
I was setting the first field to YYYYMMDD. This is always greater than the max allowed versions and it was leading to unpredictable results, to say the least, when Launch Services was deciding which version of an app to run when you had multiple versions installed and were using something like 'open -a Appname' from the command line.
我将第一个字段设置为 YYYYMMDD。这总是大于允许的最大版本,并且至少可以说,当 Launch Services 决定运行哪个版本的应用程序时,当您安装了多个版本并使用诸如“open -a Appname”之类的东西时,这会导致不可预测的结果' 从命令行。
Please spread this widely. I am sure a lot of people are coming unstuck with this.
请广泛传播。我相信很多人对此感到困惑。
回答by Kenny Evitt
As-of now, the Apple documentation for CFBundleVersion
states [emphasis mine]:
截至目前,AppleCFBundleVersion
各州的文档[强调我的]:
The build version that identifies an iteration of the bundle.
...
This key is a machine-readable string composed of one to three period-separated integers, such as 10.14.1. The string can only contain numeric characters (0-9) and periods.
...
You can include more integers but the system ignores them.
标识包迭代的构建版本。
...
此键是由一到三个以句点分隔的整数组成的机器可读字符串,例如 10.14.1。该字符串只能包含数字字符 (0-9) 和句点。
...
您可以包含更多整数,但系统会忽略它们。
For CFBundleShortVersionString
[emphasis mine]:
对于CFBundleShortVersionString
[强调我的]:
The release or version number of the bundle.
...
This key is a user-visible string for the versionof the bundle. The required format is three period-separated integers, such as 10.14.1. The string can only contain numeric characters (0-9) and periods.
捆绑包的发行版或版本号。
...
此键是捆绑版本的用户可见字符串。所需的格式是三个以句点分隔的整数,例如 10.14.1。该字符串只能包含数字字符 (0-9) 和句点。
I'd suggest just automatically incrementing CFBundleVersion
for each build (or every release to TestFlight) and resetting it to 0 whenever you change CFBundleShortVersionString
.
我建议CFBundleVersion
为每个构建(或每个 TestFlight 版本)自动递增,并在更改时将其重置为 0 CFBundleShortVersionString
。
You should explicitly plan, or devise a consistent means, to update the user visible version in CFBundleShortVersionString
.
您应该明确计划或设计一致的方法来更新CFBundleShortVersionString
.