How can this be achieved? I would like to get the name so i can display it within an app, without having to change it in code each time i change a name, of course.
Good answers here. I would add one thing though.
Rather than using @"CFBundleDisplayName", which has the potential to change in future, it's best to cast the string constant supplied in CFBundle.h like so:
[[[NSBundle mainBundle] infoDictionary] objectForKey:(NSString*)kCFBundleNameKey];
Thus future-proofing your code.
You can use the direct approach,
NSString* appName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"];
Try this
NSBundle *bundle = [NSBundle mainBundle];
NSDictionary *info = [bundle infoDictionary];
NSString *prodName = [info objectForKey:@"CFBundleDisplayName"];
let productName = Bundle.main.infoDictionary?["CFBundleName"] as? String
let displayName = Bundle.main.infoDictionary?["CFBundleDisplayName"] as? String
Here is the Xamarin.iOS version of @epatel's answer:
var prodName = NSBundle.MainBundle.InfoDictionary.ObjectForKey(new NSString("CFBundleDisplayName")) as NSString;
You could have all bundle details from this dictionary "info". print this dictionary and get what you want.
NSBundle *bundle = [NSBundle mainBundle];
NSDictionary *info = [bundle infoDictionary];