Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's best practice when it comes to Info.plist Variables in iOS development?

I recently started developing iOS Apps, and I found a Environment Variables tab in my Info.plist file. What's best practice when it comes to these variables? Can I use them throughout my code base? As long as I reference them in the correct manner?

For example if I was trying to access a Var to change the background color I could access the value this way, but is it reliable? Is it best practice? I simply can see the benefit of being able to access these vars across multiple ViewControllers and Delegates.

enter image description here

like image 940
Miguel Solano Avatar asked Jun 15 '16 12:06

Miguel Solano


People also ask

What is the use of info plist in iOS?

The Info. plist file contains critical information about the configuration of an iOS mobile app—such as iOS versions that are supported and device compatibility—which the operating system uses to interact with the app. This file is automatically created when the mobile app is compiled.

What kind of settings would you store in your info plist file?

Suggested approach: The Info. plist file stores settings that must be available even when the app isn't running. You could talk about custom URLs, privacy permission messages, custom fonts, whether the app disables background running, and so on.

What is the use of info plist?

A common property list in iOS projects is the Info. plist file. This plist contains information about your iOS project. It's distributed as part of your app's binary package, and iOS uses it for example to display your app's name on an iPhone's home screen.

What is the use of info plist in Xcode?

Xcode supplies an information property list file when you create a project from a template, as described in Create a project. By default, Xcode names this file Info. plist and adds it to your project as a source file that you can edit. Xcode creates one information property list for each target in the project folder.


1 Answers

It's much easier to define constants like that in code.

  1. You know their type for sure -> no typecasting needed
  2. You could document them properly
  3. You don't have to remember their keys in the info.plist. Xcode's code-completion will help you when you use the constants
  4. Constants defined in code can't be manipulated by the user as easy as in the info.plist
like image 111
FelixSFD Avatar answered Nov 15 '22 00:11

FelixSFD