How do I get the current version of my iOS project in code?

后端 未结 8 1327
挽巷
挽巷 2020-12-12 10:23

I would like to be able to get the current version of my iOS project/app as an NSString object without having to define a constant in a file somewhere. I don\'t

8条回答
  •  独厮守ぢ
    2020-12-12 10:53

    An open source project of mine, App Update Tracker, offers this functionality (and more) in the form of class methods:

    • + (NSString *)getShortVersionString
    • + (NSString *)getLongVersionString

    You would use it like so:

    #import "AppUpdateTracker.h"
    
    NSLog(@"short version: %@", [AppUpdateTracker getShortVersionString]);
    NSLog(@"long version: %@", [AppUpdateTracker getLongVersionString]);
    

提交回复
热议问题