Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell 使用脚本更新CbundleShortVersionString在Xcode 11中出现错误_Shell_Plist_Watchkit_Xcode11 - Fatal编程技术网

Shell 使用脚本更新CbundleShortVersionString在Xcode 11中出现错误

Shell 使用脚本更新CbundleShortVersionString在Xcode 11中出现错误,shell,plist,watchkit,xcode11,Shell,Plist,Watchkit,Xcode11,我正在尝试使用此脚本更新主应用程序中的扩展应用程序。 一般来说,当我使用svn(我的主应用程序更新的版本)提交时,现在我还需要更新扩展版本。 我试图使用以下脚本,但似乎它给出了错误。有什么想法吗 例如: version_number=$1 build_number=$2 # echo "version_number is $version_number" echo "build_number is $build_number" pruvitInfoP

我正在尝试使用此脚本更新主应用程序中的扩展应用程序。 一般来说,当我使用svn(我的主应用程序更新的版本)提交时,现在我还需要更新扩展版本。 我试图使用以下脚本,但似乎它给出了错误。有什么想法吗

例如:

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
错误:

> 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

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

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"]}"
每次我提交它都会更新我的扩展和主应用程序。您还需要在主应用程序中添加此脚本