我有一个脚本。我用它来自动构建可在Mac Mini上为iTunes Connect上传的iOS代码。我的问题是,我必须更改CFBundleShortVersionString,以隐藏我们的内部版本控制。这也很重要,因为iTunes Connect警告我该版本无效!
#!/bin/bash
cat info.plist | grep -A1 "CFBundleShortVersionString" | sed "s/\(<string>\).*\(<\/string>\)/\1%CFBUNDLESHORTVERSION%\2/g" > info.plist_in.bk
cat info.plist_in.bk
cat info.plist | grep -A1 "CFBundleShortVersionString" | grep -v CFBundleShortVersionString | egrep "[A-z0-9]+" > delete.txt
cat delete.txt
cat info.plist | grep -v "CFBundleShortVersionString" > infoi.plist_in
cat infoi.plist_in
touch info.plist_in
cat infoi.plist_in | grep -v $(cat delete.txt) > info.plist_in
cat info.plist_in.bk >> info.plist_in
sed -i .bk2 -e "s/<\/dict>//g" info.plist_in
sed -i .bk3 -e "s/<\/plist>//g" info.plist_in
echo "</dict>" >> info.plist_in
echo "</plist>" >> info.plist_in
cat info.plist_in > info.plist
我的问题是,我收到了下一个错误:
cat: infoi.plist_in: No such file or directory
cat: delete.txt: No such file or directory
usage: grep [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A num] [-B num] [-C[num]]
[-e pattern] [-f file] [--binary-files=value] [--color=when]
[--context[=num]] [--directories=action] [--label] [--line-buffered]
[--null] [pattern] [file ...]
cat: info.plist_in.bk: No such file or directory
sed: info.plist_in: No such file or directory
cat: info.plist_in: No such file or directory
有什么想法吗?
修改 xcrun agvtool命令没有解决问题,这就是我编写自己的脚本的原因 每个命令在语法上都是正确的,当我清楚地运行它们时,代码就是我想做的。
答案 0 :(得分:2)
使用PlistBuddy
(manpage)代替编写版本字符串:
$ /usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString YourVersion" file.plist
如果您想在plist
中自动增加内部版本号(一个好主意),请参阅this SO answer。