infoDictionary内部版本号未与Plist同步 [英] infoDictionary Build Number Not Synchronized With Plist

查看:117
本文介绍了infoDictionary内部版本号未与Plist同步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照本指南在XCode iPhone项目中实现内部版本号(

I followed this guide to implementing build numbers in an XCode iPhone project (guide). I tried it and I am getting the wrong build number when NSLogging. It's not updating correctly and is always one or two numbers behind the info.plist. I need it to be the same number. Anyone know why this is happening?

即"[[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBuildNumber"]与plist的CFBuildNumber不同.

i.e "[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBuildNumber"]" is not the same as the plist's CFBuildNumber.

该脚本设置为先运行,然后再复制捆绑软件资源和所有内容.这是我得到的输出和info.plist编号:

The script is set to run first, before copy bundle resources and everything. This is the output and info.plist numbers I get:

应用程序版本:1.0构建号:52构建日期:2010年11月10日星期三15:10:05 CET
(info.plist是内部版本号:54,日期:2010年11月10日星期三15:10:43 CET)

Application Version: 1.0 Build No: 52 Build Date: Wed Nov 10 15:10:05 CET 2010
(info.plist is build number: 54 and date: Wed Nov 10 15:10:43 CET 2010)

应用程序版本:1.0构建号:54构建日期:2010年11月10日星期三15:10:43 CET
(info.plist是内部版本号:55,日期:2010年11月10日星期三15:12:54 CET)

Application Version: 1.0 Build No: 54 Build Date: Wed Nov 10 15:10:43 CET 2010
(info.plist is build number: 55 and date: Wed Nov 10 15:12:54 CET 2010)

应用程序版本:1.0构建号:54构建日期:2010年11月10日星期三15:10:43 CET
(info.plist是内部版本号:56,日期:2010年11月10日星期三,欧洲中部时间段)

Application Version: 1.0 Build No: 54 Build Date: Wed Nov 10 15:10:43 CET 2010
(info.plist is build number: 56 and date: Wed Nov 10 15:13:49 CET 2010)

应用程序版本:1.0构建号:56构建日期:CET 2010年11月10日星期三15:13:49
(info.plist是内部版本号:57,日期:2010年11月10日星期三15:14:46 CET)

Application Version: 1.0 Build No: 56 Build Date: Wed Nov 10 15:13:49 CET 2010
(info.plist is build number: 57 and date:Wed Nov 10 15:14:46 CET 2010)

似乎始终遵循这种模式.因此,继续将是56(真实58),58(真实59),58(真实60),60(真实61),60真实(62),62(真实63)等.

It seems to follow this pattern throughout. So continuing it would be 56 (real 58), 58 (real 59), 58 (real 60), 60 (real 61), 60 real (62), 62 (real 63) etc. etc.

该脚本(设置为在所有其他命令之前运行)是

The script (that is set to run before everything else) is:

#!/bin/bash
# Auto Increment Version Script
buildPlist="Project-Info.plist"
CFBuildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBuildNumber" $buildPlist)
CFBuildNumber=$(($CFBuildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBuildNumber $CFBuildNumber" $buildPlist
CFBuildDate=$(date)
/usr/libexec/PlistBuddy -c "Set :CFBuildDate $CFBuildDate" $buildPlist

推荐答案

因为在运行脚本"阶段之前已处理了项目的Info.plist.请参阅XCode中的生成结果"窗口.要解决此问题,您应该 1)使用仅运行脚本"类型创建新目标,并将其配置为更新版本号 2)创建一个类型为"Aggregate"的新目标,并向其中添加"Version update"目标和"you product"目标.

Because project's Info.plist processed prior to 'Run Script' phase. See 'Build results' window in XCode. To resolve this you should 1) Create new target with type "Run script only" and configure it to update version number 2) Create new target with type "Aggregate" and add to it "Version update" target and "you product" target.

因此,当您构建汇总"目标时,第一步-版本将被更新,而第二步-您的产品.

So when you build "Aggregate" target, at first step - version will be updated, and at second step - your product.

这篇关于infoDictionary内部版本号未与Plist同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆