How to use the Info.plist file in UIKit
UIKit is a framework for creating iOS and tvOS apps user interfaces. It is very important to know UIKit right now because SwiftUI (the new way in interface creating) is still young and only supports iOS 13 version and higher. So the next 2 to 4 years, UIKit will be must-know technology in native iOS development. It is cool if you want to learn SwiftUI, but if you are starting your native iOS developer way, then you need to know UIKit and Autolayout anyway. You can just look up on Objective-C and it is still in vacancies although Swift exists from 2014.
UIKit provides view architecture for our interfaces, the event handling, manage user interactions among the user and the system, animation support, document support, drawing, printing support, info about the current device, text management, search support, accessibility support, app extension support, and resource management.
In this part, we will gonna talk about Info.plist file and UIKit app requirements. It seems useless, but it is very important just to know what your app needs and how to provide info about some specific abilities of your app.
- Each UIKit project must have App icons and Launch Screen storyboard. App icons are icons for Home screen, Settings, App Store preview, etc. Launch Screen is an initial user interface. It will show to users while your app is loading. Interesting moment — you can’t animate your Launch Screen — it is just a static user interface. If you want to animate your Launch screen you can easily create the First screen identical to Launch screen and animate and this First Screen. The First screen must be a root controller in your app, and when the application will be loaded, then the Launch screen will be replaced by the First root controller, and then you can run your animation.
- App’s core objects are UIApplication, Application Delegate, UIWindow, Views and UI Objects, View Controllers, Event Loop, Documents and Data Objects.
- Required App Metadata. All required data about your app and its configuration are stored in Info.plist file. These requirements are how you communicate to the system what your app needs to run.
More About Info.plist
Official documentation reference here
Info.plist — is a property list file that contains essential configuration information for an application. It is an XML file with the dictionary in the root node of the file. The system uses these keys and values to obtain information about your app and how it is configured. The name of this file is reserved by the system and the name is case sensitive and must have an initial capital letter I. You have 2 ways to editing Info.plist file ( in Xcode interface and like a default XML file in any text editor).
- All Custom Keys in Info.plist would be ignored
- Recommended Keys for the iOS app you can find in the official documentation
- The values for many keys in an information property list file are human-readable strings that are displayed to the user by the Finder or your own app. When you localize your app, you should be sure to localize the values for these strings in addition to the rest of your app’s content. (Commonly localized strings CFBundleDisplayName, CFBundleName, CFBundleShortVersionString, NSHumanReadableCopyright)
How to find a new Info.plist file place?
In a huge project, you will have a difficult structure of folders and sometimes you will need to move Info.plist file to another folder. Like on the image below:
So, Info.plist file moved to the Configuration folder and you got this issue — Build input file cannot be found: ‘/path/Info.plist’.
We need to find Build Settings -> Packaging -> Info.plist value.
And we need to write the full path to our Info.plist file. In this project — this is TestApp/Configuration/Info.plist.
Why do we need Info.plist file?
- It contains an app display name (with InfoPlist.strings file you can provide a multilanguage name for your app).
- Information about the version of an app and type of bundle. It can be an application, console app, framework.
- It contains an app unique identifier for AppStore.
- If your app has abilities like below, then you need to provide info about these abilities in Info.plist. This is a list of most regular of them:
-Custom fonts used in an app.
-Info about a Home Screen Widget.
-Info about Background modes (audio, voip, remote-notifications, external-accessory, bluetooth-central, bluetooth-peripheral).
-Info about IPad support and app orientation (Portrait, PortraitUpsideDown, LandscapeLeft, LandscapeRight).
-Info about visibility status bar
-Info about storyboards (Launch and Main)
-Required device capabilities(accelerometer, arkit, auto-focus-camera, gamekit, gyroscope, healthkit, location-services, magnetometer, microphone)
So, if your app needs some of the abilities like above — you need to add this requirement to your Info.plist