Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6626147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:51:33+00:00 2026-05-25T21:51:33+00:00

I would like to be able to get the current version of my iOS

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T21:51:34+00:00Added an answer on May 25, 2026 at 9:51 pm

    You can get the version and build numbers as follows:

    let version = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
    let build = Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as! String
    

    or in Objective-C

    NSString * version = [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleShortVersionString"];
    NSString * build = [[NSBundle mainBundle] objectForInfoDictionaryKey: (NSString *)kCFBundleVersionKey];
    

    I have the following methods in a category on UIApplication:

    extension UIApplication {
    
        static var appVersion: String {
            return Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as! String
        }
    
        static var appBuild: String {
            return Bundle.main.object(forInfoDictionaryKey: kCFBundleVersionKey as String) as! String
        }
    
        static var versionBuild: String {
            let version = appVersion, build = appBuild            
            return version == build ? "v\(version)" : "v\(version)(\(build))"
        }
    }
    

    Gist: https://gist.github.com/ashleymills/6ec9fce6d7ec2a11af9b


    Here’s the equivalent in Objective-C:

    + (NSString *) appVersion
    {
        return [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleShortVersionString"];    
    }
    
    + (NSString *) build
    {
        return [[NSBundle mainBundle] objectForInfoDictionaryKey: (NSString *)kCFBundleVersionKey];
    }
    
    + (NSString *) versionBuild
    {
        NSString * version = [self appVersion];
        NSString * build = [self build];
    
        NSString * versionBuild = [NSString stringWithFormat: @"v%@", version];
    
        if (![version isEqualToString: build]) {
            versionBuild = [NSString stringWithFormat: @"%@(%@)", versionBuild, build];
        }
    
        return versionBuild;
    }
    

    Gist: https://gist.github.com/ashleymills/c37efb46c9dbef73d5dd

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to be able to get a list of all possible files
I would like to be able to get the name of a variable as
I would like to be able to get as many properties from a button
I would like to be able to get a list of parameters in the
I have a TcxScheduler where I would like to be able to get the
i would like an index action to be able to take get and post
I would like to get the current element (whatever element that is) in an
I am starting a project and i would like to be able to test
I would like to get the current time on the android device with the
I would like to be able to get the speed of the wireless interface

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.