我有一个构建脚本,它从iOs产品的pllist中取出旧版本,输出它,然后更新pllist。这两个命令是
/usr/libexec/PlistBuddy -c Print CFBundleVersion ${LocationOfPList}
/usr/libexec/PlistBuddy -c Set :CFBundleVersion ${Version} ${LocationOfPList}
从命令行运行(使用版本和正确的PList文件位置),一切正常。从ant运行
<exec executable="/usr/libexec/PlistBuddy"
outputproperty="CurrentVersion"
errorproperty="PListError">
<arg value="-c"/>
<arg value ="Print :CFBundleVersion"/>
<arg value="${LocationOfPList}"/>
</exec>
<echo message="Fetched the last version in the plist: ${CurrentVersion}" />
<!-- Set the plist to the current build number -->
<exec executable="/usr/libexec/PlistBuddy"
outputproperty="PListOutput"
errorproperty="PListError"
>
<arg value="-c"/>
<arg value ="Set :CFBundleVersion ${Version}" />
<arg value=" ${LocationOfPList}"/>
</exec>
<echo message="Output: ${PListOutput}"/>
<echo message="Errors: ${PListError}"/>
<echo message="Old version number: ${CurrentVersion} New Version Number: ${Version}" />
导致一些奇怪的行为。第一个命令有效,第二个命令失败。此ant脚本以与命令行示例相同的用户运行。我看到的输出是:
[echo] Fetched the last version in the plist: 3.0.0
[exec] Result: 1
[echo] Output: File Doesn't Exist, Will Create: /Users/macbuild/iPhone/branches/anttest/iChime/Program-Info.plist
[echo] Errors:
[echo] Old version number: 3.0.0 New Version Number: anttest
plist没有更新,唯一的命中是返回代码1。我是发布工程师,我不懂xcode。有人知道我哪里做错了吗?
在set命令中的plist位置前有一个前导空格:
<!-- v -->
<arg value=" ${LocationOfPList}"/>
这是一个看不见的错误——你可能会注意到错误信息中"Will Create:"one_answers"/Users"之间有两个空格。把空格去掉就行了
同样,PListError
属性被第一个执行命令设置为一个空字符串,而Ant属性是不可变的,因此第二个执行命令没有错误文本。