
- iOS Tutorial
- iOS - Home
- iOS - Getting Started
- iOS - Environment Setup
- iOS - Objective-C Basics
- iOS - First iPhone Application
- iOS - Actions and Outlets
- iOS - Delegates
- iOS - UI Elements
- iOS - Accelerometer
- iOS - Universal Applications
- iOS - Camera Management
- iOS - Location Handling
- iOS - SQLite Database
- iOS - Sending Email
- iOS - Audio & Video
- iOS - File Handling
- iOS - Accessing Maps
- iOS - In-App Purchase
- iOS - iAd Integration
- iOS - GameKit
- iOS - Storyboards
- iOS - Auto Layouts
- iOS - Twitter & Facebook
- iOS - Memory Management
- iOS - Application Debugging
- iOS Useful Resources
- iOS - Quick Guide
- iOS - Useful Resources
- iOS - Discussion
How to get the build/version number of an iOS App?
In this post we will learn how to fetch and show the iOS build and version number
Step 1 − Open Xcode → New Project → Single View Application → Let’s name it “ShowBuildAndVersion”
Step 2 − Open Main.storyboard and add two labels as shown below.
Step 3 − Attach @IBOutLets for the two labels
@IBOutlet weak var buildLabel: UILabel! @IBOutlet weak var versionLabel: UILabel!
Step 4 − Change the build and version from project settings.
Step 5 − In viewDidLoad of ViewController get the build and version number for infoDictionary of main bundle. Show it on the corresponding labels.
override func viewDidLoad() { super.viewDidLoad() if let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String { versionLabel.text = "Version: \(version)" } if let build = Bundle.main.infoDictionary?["CFBundleVersion"] as? String { buildLabel.text = "Build: \(build)" } }
The infoDictionary in main bundle contains these values, with ‘CFBundleShortVersionString’ and ‘CFBundleVersion’ keys.
We can refer these keys to get the version and build number respectively
Step 6 − Run the project, you should see the build and version number.
- Related Articles
- How to get the Build Version number of an android app?
- How do I get the version and build number of an application using Swift?
- How to get the current version of my iOS project in code?
- How to get the dimensions of a view in iOS App?
- How to create CollectionView Layout in an iOS App?
- How to get programmatically android version number?
- How do I programmatically “restart” an iOS app?
- How much does it cost to make an iOS app?
- How to create Tab Bar Layout in an iOS App?
- Launching the App Store from an iOS application
- How to make an HTTP request on iOS App using Swift?
- How to create a WebView in an iOS App using Swift?
- How to get the MAC address of an iOS/iPhone programmatically?
- How to check notifications status for the iOS App
- How to make an HTTP POST request on iOS App using Swift?
