Info.plist. Read Content of a Property File in Swift

In this short Swift code example I am going to share with you how to load content of a property file into NSDictionary. And in this particular example I will load content of Info.plist file which is available in our projects. But you can use this approach to load up content of any property file you create in your iOS app Xcode project.

  • Use Bundle.main.path to determine the path to a Info.plist property file
  • Create NSDictionary with a content of a property file
  • Print out the value of one of the Info.plist property file keys

Info.plist. Load Content of a Property File into NSDictionary

import UIKit

class ViewController: UIViewController  {

override func viewDidLoad() {

override func viewWillAppear(_ animated: Bool) {
    var resourceFileDictionary: NSDictionary?
    //Load content of Info.plist into resourceFileDictionary dictionary
    if let path = Bundle.main.path(forResource: "Info", ofType: "plist") {
        resourceFileDictionary = NSDictionary(contentsOfFile: path)
    if let resourceFileDictionaryContent = resourceFileDictionary {
        // Get something from our Info.plist like MinimumOSVersion
        print("MinimumOSVersion = \(resourceFileDictionaryContent.object(forKey: "MinimumOSVersion")!)")
        //Or we can print out entire Info.plist dictionary to preview its content

Checkout more Swift code examples at Swift Code Examples page.

Learn iOS Development with these Video Courses

How to Make a Freaking iPhone App - iOS 10 and Swift 3
icon icon

iOS 10 & Swift 3: From Beginner to Paid Professional

The Complete iOS 10 Developer Course - Build 21 Apps

Swift 3 - Learn to Code with Apple's New Language
icon icon

Learn How to Build Mobile Apps for iOS with Swift, PHP and MySQL
icon icon

Follow me on one of your favourite social networks to learn about new video tutorials and code examples:

Twitter: @SwiftVideoBlog
Google Plus:
Facebook: Swift Developer Blog on Facebook