大佬教程收集整理的这篇文章主要介绍了Xcode 4:使用Git repo commit版本在每个构建上更新CFBundleVersion,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我发现that python脚本运行良好,但遗憾的是它没有更新我的Xcode项目中的Info.plist – 它只是更新了“BUILT_PRODUCTS_DIR”中的Info.plist.
有没有人知道如何让Xcode 4获取最新提交的版本并将该信息放入项目的Info.plist中?
谢谢!
我通过使用git标签为x和y(例如0.4)提供有意义的标记号来处理这个问题,然后通过脚本构建阶段,z获取自git describe返回的自上一个标记以来的提交数.
这是我从this one改编的脚本.它可以作为构建阶段直接添加到目标(sHell是/usr/bin/env ruby):
# add git tag + version number to Info.plist version = `/usr/bin/env git describe`.chomp puts "raw version "+version version_fancy_re = /(\d*\.\d*)-?(\d*)-?/ version =~ version_fancy_re commit_num = $2 if ( $2.empty? ) commit_num = "0" end fancy_version = ""+$1+"."+commit_num puts "compatible: "+fancy_version # BACkup source_plist_path = File.join(ENV['PROjeCT_DIR'],ENV['INFOPLIST_FILE']) orig_plist = File.open( source_plist_path,"r").read; File.open( source_plist_path+".bak","w") { |file| file.write(orig_plist) } # put in CFBundLeversion key version_re = /([\t ]+<key>CFBundLeversion<\/key>\n[\t ]+<String>).*?(<\/String>)/ orig_plist =~ version_re bundle_version_String = $1 + fancy_version + $2 orig_plist.gsub!(version_re,bundle_version_String) # put in CFBundleShortVersionString key version_re = /([\t ]+<key>CFBundleShortVersionString<\/key>\n[\t ]+<String>).*?(<\/String>)/ orig_plist =~ version_re bundle_version_String = $1 + fancy_version + $2 orig_plist.gsub!(version_re,bundle_version_String) # write File.open(source_plist_path,"w") { |file| file.write(orig_plist) } puts "Set version String to '#{fancy_version}'"
以上是大佬教程为你收集整理的Xcode 4:使用Git repo commit版本在每个构建上更新CFBundleVersion全部内容,希望文章能够帮你解决Xcode 4:使用Git repo commit版本在每个构建上更新CFBundleVersion所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。