Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieve info.plist file from command-line tool

Using the following steps, I'm able to embed an info.plist into a command-line tool.

http://developer.apple.com/library/mac/#documentation/Security/Conceptual/CodeSigningGuide/Procedures/Procedures.html

I know how to retrieve the plist file from a .bundle, but I'm not sure how to do the same in a single-file tool like I've got.

I've embedded the info.plist into the command-line tool so that I can store the version in it. Does anyone know how I can retrieve it at run-time so I can determine what version is running?

Thanks

like image 514
bugfixr Avatar asked Oct 17 '11 18:10

bugfixr


1 Answers

__info_plist is a "magic" section name that makes the following Just Work:

NSBundle *bundle = [NSBundle mainBundle];
id version = [bundle objectForInfoDictionaryKey: (NSString*) kCFBundleVersionKey];
NSLog(@"mainBundle.version = %@", version);

If you need to read a bundle embedded in a different executable than the one currently running, this answer by Bavarious from the comments has a more comprehensive list of approaches.

like image 191
millimoose Avatar answered Oct 16 '22 06:10

millimoose