bash脚本编辑PROJECT-Info.plist文件中的CFBundleVersion领域 [英] Bash script to edit CFBundleVersion field of PROJECT-Info.plist file
问题描述
在为建立一个持续集成系统,哈德森,我写了一个bash脚本来自动创建X code ++项目。
此外,在调试配置,有人问我,插在PROJECT-Info.plist文件为$ {} BUNDLE_VERSION .R $ {} SVN_REVISION的CFBundleRevision领域项目的SVN版本号。
您会发现下面PROJECT-Info.plist文件的来源$ C $ C:
<?XML版本=1.0编码=UTF-8&GT?;
!< DOCTYPE的plist PUBLIC - //苹果// DTD PLIST 1.0 // ENhttp://www.apple.com/DTDs/PropertyList-1.0.dtd\">
<的plist版本=1.0>
<&字典GT;
[...]
<密钥GT; CFBundleVersion< /键>
<串GT; 1.0 LT; /串>
[...]
< /字典>
< / plist中>
我试过低于这个bash脚本:
SED 'N;s_^.*<key>CFBundleVersion</key>.*<string>[0-9][0-9]*\\.[0-9][0-9]*</string>$_<key>CFBundleVersion</key>\\
&LT;串GT;'$ BUNDLE_VERSION'\\ r'$ SVN_REVISION'&LT; /串&GT; _'$ PROJECT-的Info.plist
本脚本应该以$ {} BUNDLE_VERSION .R $ {} SVN_REVISION(刚刚在标准输出当前)取代1.0字符串。
然而,更换工作,而不N选项,其中包括在所述的sed过程并在每次一行的下一行。但有许多行&LT;串&GT; [...] LT; /串&GT;
字符串中的PROJECT-Info.plist文件...
我觉得这是我的处理两条线之间的未知字符的方式(N选项和*任何字符)是错误的。
任何想法?
在此先感谢和抱歉的英语是我不好的水平。
$ myversion = 1.0.3
$ perl的-O777 -i.bak -pe 's|<key>CFBundleVersion</key>\\\\s*<string>[\\d.]*</string>|<key>CFBundleVersion</key></key>'\"$myversion\"'<string>|'束
将文件捆绑
到 bundle.bak
,并取代 1.0.6.9
与 1.0.3
新捆绑
文件。
In order to put in place a continuous integration system, Hudson, I wrote a bash script to build Xcode project automatically. Moreover, in Debug configuration, It was asked to me, to insert the svn revision number of the project in the CFBundleRevision field of the PROJECT-Info.plist file as ${BUNDLE_VERSION}.r${SVN_REVISION}.
You'll find the source code of PROJECT-Info.plist file below :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
[...]
<key>CFBundleVersion</key>
<string>1.0</string>
[...]
</dict>
</plist>
I tried this bash script below :
sed 'N;s_^.*<key>CFBundleVersion</key>.*<string>[0-9][0-9]*\.[0-9][0-9]*</string>$_<key>CFBundleVersion</key>\
<string>'"$BUNDLE_VERSION"'\.r'"$SVN_REVISION"'</string>_' $PROJECT-Info.plist
This script should replace the "1.0" string with ${BUNDLE_VERSION}.r${SVN_REVISION} (just in standard output currently).
However, the replacement works without the 'N' option which includes the next line in the sed process and for one line at a time. But there is many line with "<string>[...]</string>
" string in the PROJECT-Info.plist file...
I think it's my way of processing the unknown characters between the two lines ('N' option and ".*" for any characters) is wrong.
Any idea ?
Thanks in advance and sorry for my bad level in English.
$ myversion=1.0.3
$ perl -O777 -i.bak -pe 's|<key>CFBundleVersion</key>\\s*<string>[\d.]*</string>|<key>CFBundleVersion</key></key>'"$myversion"'<string>|' bundle
Moves the file bundle
to bundle.bak
, and replaces 1.0.6.9
with 1.0.3
in the new bundle
file.
这篇关于bash脚本编辑PROJECT-Info.plist文件中的CFBundleVersion领域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!