我正在將 Xcode 4與 Git結合使用,并希望在每個版本得Info.plist中增加CFBundleVersion.密鑰CFBundleVersion得值應更新為我對Git存儲庫得最后一次提交得數量.
我發現that python腳本運行良好,但遺憾得是它沒有更新我得Xcode項目中得Info.plist – 它只是更新了“BUILT_PRODUCTS_DIR”中得Info.plist.
有沒有人知道如何讓Xcode 4獲取最新提交得版本并將該信息放入項目得Info.plist中?
謝謝!
解決方法
版本字符串必須是格式[xx].[yy].[zz]其中x,y,z是數字.
我通過使用git標簽為x和y(例如0.4)提供有意義得標記號來處理這個問題,然后通過腳本構建階段,z獲取自git describe返回得自上一個標記以來得提交數.
這是我從this one改編得腳本.它可以作為構建階段直接添加到目標(shell是/usr/bin/env ruby??):
# add git tag + version number to Info.plistversion = `/usr/bin/env git describe`.chompputs "raw version "+versionversion_fancy_re = /(d*.d*)-?(d*)-?/version =~ version_fancy_recommit_num = $2if ( $2.empty? )commit_num = "0"endfancy_version = ""+$1+"."+commit_numputs "compatible: "+fancy_version# backupsource_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 keyversion_re = /([t ]+<key>CFBundleVersion</key>n[t ]+<string>).*?(</string>)/orig_plist =~ version_rebundle_version_string = $1 + fancy_version + $2orig_plist.gsub!(version_re,bundle_version_string)# put in CFBundleShortVersionString keyversion_re = /([t ]+<key>CFBundleShortVersionString</key>n[t ]+<string>).*?(</string>)/orig_plist =~ version_rebundle_version_string = $1 + fancy_version + $2orig_plist.gsub!(version_re,bundle_version_string)# writeFile.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所遇到得程序開發問題。
如果覺得來客網網站內容還不錯,歡迎將來客網網站推薦給程序員好友。
聲明:所有內容來自互聯網搜索結果,不保證100%準確性,僅供參考。如若本站內容侵犯了原著者的合法權益,可聯系我們進行處理。