首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用脚本更新CFBundleShortVersionString会导致Xcode 11中的错误

用脚本更新CFBundleShortVersionString会导致Xcode 11中的错误
EN

Stack Overflow用户
提问于 2020-06-22 17:27:27
回答 1查看 284关注 0票数 0

我试图用这个脚本更新我的扩展应用程序,它在主应用程序中。一般来说,当我与svn一起提交时,我的主要应用程序更新版本,现在我也需要更新扩展版本。我试图使用以下脚本,但似乎会出错。知道吗?

这是一个例子:

代码语言:javascript
复制
version_number=$1
build_number=$2
#
echo "version_number is $version_number"
echo "build_number is $build_number"



pruvitInfoPlist="ServiceExtension/Info.plist"
/usr/libexec/PlistBuddy -c "Set CFBundleShortVersionString $version_number" $pruvitInfoPlis

错误:

代码语言:javascript
复制
> Build/file.rb:41: syntax error, unexpected unary-, expecting do or '{'
> or '(' /usr/libexec/PlistBuddy -c "Set CFBundleShortVersionSt...
>                         ^ Build/file.rb:41: syntax error, unexpected tGVAR, expecting end-of-input ...ersion_number" $pruvitInfoPlist ...  
> ^~~~~~~~~~~~~~~~ Command PhaseScriptExecution failed with a nonzero
> exit code
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-06-23 13:02:48

我将在这里回答我的问题,也许在这里可以帮助别人。我用扩展脚本解决了这个问题。

代码语言:javascript
复制
plistFile = "#{ENV['BUILT_PRODUCTS_DIR']}/#{ENV['INFOPLIST_PATH']}"
`/usr/bin/plutil -convert xml1 "#{plistFile}"`
unless pl = Plist::parse_xml(plistFile) 
    puts "Could parse #{plistFile}"
    exit
end

freshPlFile = "#{ENV['SOURCE_ROOT']}/ServiceExtension/Info.plist"
`/usr/bin/plutil -convert xml1 "#{freshPlFile}"`
unless freshPl = Plist::parse_xml(freshPlFile)
    puts "Could parse #{freshPlFile}"
   exit
end




version = pl["CFBundleShortVersionString"].gsub(/ \([a-f0-9 \/:]*\)/, '')
# keep only the major and minor version number and add the revision
version.gsub!(/([^\.]*)\.([^\.]*).*/, "\\1.\\2.#{revision}");


pl["CFBundleShortVersionString"] = version
pl["CFBundleVersion"] = Time.now.utc.strftime("%Y%m%d%H")

pl.save_plist(plistFile)

`/usr/bin/plutil -convert binary1 #{plistFile}`

puts "#{plistFile}:"
puts "CFBundleVersion = #{pl["CFBundleVersion"]}"
puts "CFBundleShortVersionString = #{pl["CFBundleShortVersionString"]}"

每次我提交它,更新我的扩展和我的主要应用程序。您还需要在主应用程序中添加此脚本。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62520154

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档