Josh Schumacher: A PHP Developer

The biggest and the best in the Northwest

Josh Schumacher: A PHP Developer random header image

Reading Common and Custom Values From Your Info.plist

February 19th, 2009 · 10 Comments

It seems like a pretty simple, common thing you would want to do in objective-c right?  All applications have an Info.plist (or a different plist file as defined in your “Info.plist File” property of your build target).  I’ve been pretty frustrated with the quality of google search results when trying to figure out how to do more or less mundane things with the iPhone SDK.  I’m going to start writting posts, especially when I have a hard time trying to find what I was looking for in search results.

Here’s the quick and dirty: I have a game that we’re building here at Treemo Labs, Tic A Tac Poker. We’re working on getting a lite version out the door. I wanted to read a custom value out of the Info.plist to tell if it’s the lite version or not. I couldn’t figure out how to read a simple value from the default property list file. Here’s some sample code to get the bundleIdentifier, bundle version and custom values from your Info.plist

  1. // Create a new NSBundle pointer
  2. NSBundle* mainBundle;
  4. // The Info.plist is considered the mainBundle.
  5. mainBundle = [NSBundle mainBundle];  
  7. // Reads the value of the custom key I added to the Info.plist
  8. [mainBundle objectForInfoDictionaryKey:@"myCustomKey"]
  10. // Another handy thing I had to search around for a little
  11. // Get the value for the "Bundle version" from the Info.plist
  12. [mainBundle objectForInfoDictionaryKey:@"CFBundleVersion"]
  14. // Need the bundle identifier? (probably something like com.mycorp.product)
  15. [mainBundle bundleIdentifier]

For more information about the NSBundle, view the NSBundle Reference Documentation.

To see an alphabetical list of the standard keys you can use in an information property list file, along with a brief description and the platforms to which they apply (Mac OS X or iPhone) check out the Property List Key Reference.

Tags: iPhone Development · iPhone SDK · Objective-C

10 responses so far ↓

  • 1 Vishal Sharma // Oct 16, 2009 at 8:21 pm

    THx Buddy for ur valuable Code

  • 2 Tom Lynch // Mar 9, 2010 at 4:21 pm

    Thanks so much for that!

  • 3 Eddie // Jun 22, 2010 at 1:40 pm


    You can find more information here:


  • 4 aONe // Nov 11, 2010 at 7:20 pm

    Thanks for that info! Will use this for Keka 😉

  • 5 David Cardoso // Dec 13, 2011 at 5:43 pm

    Thanks so much, simple enough but effectively works. Other examples I was finding on the web were much more complex and did not do the job. Yours is really simple and really works!!!

    Awesome!! Thanks again!

  • 6 Donie // Jan 6, 2012 at 2:26 am

    Nice one. Simple and effective

  • 7 Seth U. // Jan 11, 2012 at 2:27 pm

    Thank you very much for posting this. I also had poor Google search results.

  • 8 Andreas Wacker // Feb 25, 2012 at 1:38 am

    Thank you for taking the time to write this. Saved me -yet another- trip into the horrors and oddities of google-cocoa-land.

  • 9 Ajay // Jun 11, 2012 at 6:33 am

    hi is there any way to access CFBundleVersion in safari extension’s info.plist file.

  • 10 cinnamon // Dec 8, 2012 at 1:49 pm

    Thank you for nice tip! It helps me a lot 🙂

Leave a Comment