iOS 扩展:是否需要增加它的包版本(CFBundleVersion)?

iOS Extension: Is it necessary to increment its bundle version (CFBundleVersion)?

我是否必须增加扩展 Info.plist 中的 CFBundleVersion 以确保它覆盖现有的?或者如果在主应用程序的 Info.plist 中这样做就足够了?

我正在研究今天的扩展,但我想这个问题适用于所有嵌入式二进制文件。

这两种方式都没有记录,所以你应该更新它。这可能无关紧要,但您不能确定,即使现在没有必要,以后也可能会变得有必要。作为未记录的细节,它可能会在没有警告的情况下更改。

这也是很好的软件开发实践。每当扩展更改时,嵌入式版本号都应该更改,即使 iOS 不对信息做任何事情。

我认为 Apple 实际上更希望 App Extensions 使用与其包含的应用程序相同的捆绑包版本。这是我在每次提交时从 iTunes Connect 收到的电子邮件:

We have discovered one or more issues with your recent delivery for "Awesome App". Your delivery was successful, but you may wish to correct the following issues in your next delivery:

CFBundleVersion Mismatch - The CFBundleVersion value '94' of extension 'Awesome App.app/PlugIns/Awesome App Today Extension.appex' does not match the CFBundleVersion value '99' of its containing iOS application 'Awesome App.app'.

CFBundleShortVersionString Mismatch - The CFBundleShortVersionString value '1.0' of extension 'Awesome App.app/PlugIns/Awesome App Today Extension.appex' does not match the CFBundleShortVersionString value '1.3.0' of its containing iOS application 'Awesome App.app'.

After you’ve corrected the issues, you can use Xcode or Application Loader to upload a new binary to iTunes Connect.

我可以忽略这些警告并且构建通过审核,但这要么是 iTunes Connect 中的错误,要么数字应该相同。这实际上没有意义,因为扩展不一定会以与应用程序相同的速度更新。不管怎样

我一直在寻找相同的答案,我最近刚刚更新了一个应用程序,发现在上传时,我收到了有关扩展程序和版本号与应用程序不匹配或其他内容的警告, (不记得具体的措辞)-因此我在这里!

"App Extensions and their containing apps must use the same build number (CFBundleVersion) and version number (CFBundleShortVersionString) as used in the other targets in the Xcode project."

信息不多,但很清楚 - App 扩展和 WatchKit 扩展的版本必须与其所在应用程序的版本匹配。

即使给我们一个选项来指定单独的版本号似乎有点毫无意义,不是吗?

是的,扩展包版本(包版本 && 包版本字符串,短)必须与主应用构建 && 版本不匹配。

所以, 捆绑版本扩展 = 主应用构建

捆绑包版本字符串,简称 = 主应用程序版本

为了避免来自 iTunes Connect 的警告,我只是从主应用程序的 "Bump build number" 构建脚本中修改所有版本号:

if [ "$BUMP_BUILD_NUMBER" = "1" ] ; then
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${INFOPLIST_FILE}")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "${INFOPLIST_FILE}"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "/Users/name/project/ios/Siri/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "/Users/name/project/ios/SiriUI/Info.plist"
fi
``

基于@atomkirk 的回答,在我的应用程序中,版本号和内部版本号设置在 xcodeproject 中。因此,我不需要使用 xcodebuild 来提取相关值:

buildNumber=$(xcodebuild -showBuildSettings -project App.xcodeproj | pcregrep -o1 "PROJECT_VERSION = ([0-9a-f\-]+)")
marketingVersion=$(xcodebuild -showBuildSettings -project App.xcodeproj | pcregrep -o1 "MARKETING_VERSION = ([0-9a-f\-.]+)")

/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$SRCROOT/Share Extension/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString $marketingVersion" "$SRCROOT/Share Extension/Info.plist"