我有一个脚本。我让它为 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 命令没有解决问题,这就是我编写自己的脚本的原因
每个命令在语法上都是正确的,当我清楚地运行它们时,代码会做我想做的事。
Best Answer-推荐答案 strong>
使用 PlistBuddy ( manpage ) 来编写版本字符串:
$ /usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString YourVersion" file.plist
如果您想在 plist 中自动增加内部版本号(一个好主意),请参阅 this SO answer .
关于ios - 在 OSX 中写入文件,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/28146151/
|