ios - 在 OSX 中写入文件
<p><p>我有一个脚本。我让它为 Mac Mini 上的 iTunes Connect 自动构建可上传的 iOS 代码。我的问题是,我必须更改 CFBundleShortVersionString,以隐藏我们的内部版本控制。这也很重要,因为 iTunes Connect 会警告我版本无效!</p>
<pre><code>#!/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 "+" > 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
</code></pre>
<p>我的问题是,我得到了下一个错误:</p>
<pre><code>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]
[-e pattern] [-f file] [--binary-files=value] [--color=when]
[--context[=num]] [--directories=action] [--label] [--line-buffered]
[--null]
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
</code></pre>
<p>有什么想法吗?</p>
<p><strong>编辑:</strong>
xcrun agvtool 命令没有解决问题,这就是我编写自己的脚本的原因
每个命令在语法上都是正确的,当我清楚地运行它们时,代码会做我想做的事。 </p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>使用 <code>PlistBuddy</code> ( <a href="https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man8/PlistBuddy.8.html" rel="noreferrer noopener nofollow">manpage</a> ) 来编写版本字符串:</p>
<pre><code>$ /usr/libexec/PlistBuddy -c "Set :CFBundleShortVersionString YourVersion" file.plist
</code></pre>
<p>如果您想在 <code>plist</code> 中自动增加内部版本号(一个好主意),请参阅 <a href="https://stackoverflow.com/questions/9258344/better-way-of-incrementing-build-number" rel="noreferrer noopener nofollow">this SO answer</a> .</p></p>
<p style="font-size: 20px;">关于ios - 在 OSX 中写入文件,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/28146151/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/28146151/
</a>
</p>
页:
[1]