简体   繁体   中英

How to get target's version by Ruby (or Xcodeproj)

How to get target's version(The version of you APP) in Ruby or Xcodeproj ?

I have tried sdk_version in AbstractTarget with Xcodeproj, But it returns nil.

If Xcodeproj doesn't support it. How to get the version by Ruby ?

  • Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") should give you version number
  • Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") should give you build number

I did this in Ruby using the plist gem, like this:

require 'plist'
info = Plist.parse_xml('path/to/Info.plist')
puts info["CFBundleShortVersionString"]
puts info["CFBundleVersion"]

I hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM