3

I have a lite and a full version and want them to work with different configuration Files.

Now I need to query, within the application, if the application name has "lite" in it and load the coresponding config-file I havent found how to do it. Any Idea ? Or is there generally a better approach for that ?

Thanks in advance Heiko

Krunal
  • 77,632
  • 48
  • 245
  • 261
HeikoG
  • 1,793
  • 1
  • 20
  • 29

4 Answers4

5

If you want what was put into the Info.plist file, use:

NSString * displayName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"];
Dave DeLong
  • 242,470
  • 58
  • 448
  • 498
3

Try

[[NSProcessInfo processInfo] processName]

This returns process name, which is usually your application's name.

Akash Kava
  • 39,066
  • 20
  • 121
  • 167
2

You application has a main() in main.m (if you used a template). It gets passed the command-line arguments and argv[0] should be the full path of the application, which you can parse. You'll have to save it in a global variable.

You could also check the launchOptions in the appDelegate to see if it's there too.

Lou Franco
  • 87,846
  • 14
  • 132
  • 192
0

Try this for Swift:

if let appName = Bundle.main.infoDictionary?["CFBundleName"] as? String {
    print("App Name - \(appName)")
}

Also try this, if you've set Display Name

if let displayName = Bundle.main.infoDictionary?["CFBundleDisplayName"] as? String {
    print("App Display Name - \(displayName)")
}

Useful trick:

// Print bundle info dictionary to get complete details about app
print("Bundle.main.infoDictionary - \(Bundle.main.infoDictionary)")
Krunal
  • 77,632
  • 48
  • 245
  • 261