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 want to change my version value in 2 places.
The value needs to be updated when I bump my version in the Project target summary.
Best Answer
You can get the version and build numbers as follows:
or in Objective-C
I have the following methods in a category on
UIApplication
:Gist: https://gist.github.com/ashleymills/6ec9fce6d7ec2a11af9b
Here's the equivalent in Objective-C:
Gist: https://gist.github.com/ashleymills/c37efb46c9dbef73d5dd