2011-09-21 81 views
1

我有一个构建脚本,将旧版本从plist中拉出来用于iOs产品,输出它,然后更新plist。这两个命令是来自蚂蚁的PListBuddy失败

/usr/libexec/PlistBuddy -c Print CFBundleVersion ${LocationOfPList} 
/usr/libexec/PlistBuddy -c Set :CFBundleVersion ${Version} ${LocationOfPList} 

从命令行(使用版本和正确的PList文件位置)运行,一切都很好。从蚂蚁运行,因为

<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。有人看到我在这里做错了吗?

回答

1

你刚刚在set命令的plist位置之前有一个前导空格:

<!--  v --> 
<arg value=" ${LocationOfPList}"/> 

正是这些无形的错误之一 - 您可能会注意到两个空间之间“将创造”和“/用户“在错误信息中。 删除空间,它应该工作。

此外,PListError属性由第一个exec设置为空字符串,并且Ant属性是不可变的,因此第二个exec没有错误文本。

+0

好,但事实上并非如此。我做了一个错误的复制和粘贴作业。我的ant脚本中的行是$ {PlistBuddy},我复制了该属性(在共享属性文件中定义)以显示我正在使用的可执行文件 - 我错过了删除$和}的操作。我会在问题中解决它以避免更进一步的混淆。 – Feasoron

+0

已更新。小错字再次,但在这里重现。 –

+0

修复它。男孩,我觉得很愚蠢。 – Feasoron