Get application name

I have a lightweight and full version and want them to work with different configuration files.

Now I need to request in the application if the application name has "lite" in it and loads the corresponding configuration file. I did not find how to do this. Any ideas? Or, as a rule, is better suited for this?

Thanks in advance Heiko

+3
source share
4 answers

Try

[[NSProcessInfo processInfo] processName]

This returns the process name, which is usually your application name.

+3
source

If you want what was placed in the Info.plist file, use:

NSString * displayName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"];
+5
source

main() main.m( ). , argv [0] , . .

launchOptions appDelegate, , .

+2
source

Try this for Swift:

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

Also try if you 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)")
0
source

Source: https://habr.com/ru/post/1758522/


All Articles