iOS mobile applications for iPhone, iPad devices, require special attention thanks to the large portion of the mobile device market that Apple still owns.
The iOS Apps are developed under the IDE (Integrated Development Environment) known as Xcode, which must be installed on the MacOS operating system.
Developing iOS mobile apps requires programming skills in Apple’s Swift language, which is now open source, under license from Apache. Swift is used to create applications for Mac, iOS, Apple TV or Apple Watch. Ensuring integration with Objective C language code.
Apple recommends a series of guidelines to build iOS mobile applications that deliver a good user experience with their design, respond quickly to commands, adapt to different screen sizes, and consume as little as possible the battery of physical devices.
A) Expected Behavior of iOS Mobile Applications
When we are going to publish an iOS mobile application in the AppStore, the app is required to contain the following additional data:
- An Info.plist file containing information known as app metadata. Created automatically by Xcode.
- The hardware requirements or features that the iOS mobile app needs to run must be declared.
- It must have one or more icons to present it in the user’s application window.
- It must also have a startup image of the app, which is the image that is shown when the application is just launched and is just loading.
B) Well-defined states of execution
Applications go through several execution states from the time they are started until they are finally closed. Thus the application follows a series of execution states, when it is running in the foreground, or when it is in the background, and then it is resumed.
iOS mobile applications must then manage these states very well, in order to have the expected behavior in each of them, such as making the lowest possible battery usage while in the background.
C) Efficient execution in iOS multitasking
iOS multitasking allows to keep an app in background, reducing its battery usage, but with the ability to quickly return to its previous state, when the user returns to the App. This is why it is necessary for the mobile application to make efficient use of the multitasking aspects of iOS, to safeguard a very valuable asset for users, which is their battery charge.
D) Standard communication between iOS mobile applications
iOS and Mac have developed an access control technology known as Sandbox, which allows apps to have limited interaction with each other. So if communication between apps is required, the interfaces specified by Sandbox must be handled.
E) Performance Tuning of iOS Mobile Applications
Apple recommends to perform a series of tunings to the App, in order to make an efficient use of the different hardware resources.
Among the tips it recommends tuning to improve performance we have:
1. Efficient use of battery charge
Reduce power consumption
- Avoid polling the CPU (continuous requests to the CPU so that it does not go to sleep).
- Let the system automatically turn off the screen, without forcing it to keep it on during an unattended operation.
- Avoid frequent disk access.
- Do not draw too fast on the screen, which consumes a lot of energy.
- To gather tasks to execute them at the same time.
- Make efficient use of the accelerometer, only when necessary.
- Connect as little as possible to external servers, only when necessary, and much less polling them.
- Transmit large bursts of data in short periods of time to minimize battery-consuming WiFi or 3G/4G mobile radiation.
- Minimize the use of central location functions, so that they use GPS, cellular network and WiFi as little as possible.
- Tie tasks together, so that the system takes care of automatically evacuating them.
- Connect to WiFi networks as much as possible; cellular network connections consume more energy.
Efficient use of memory
It is recommended that Apps use as little memory as possible. This way the system will have more memory available for apps that are in the foreground, making iOS response to running mobile app tasks faster.
For this case it is recommended to:
- Handle low memory warnings, in order to free up unnecessary memory.
- Reduce app memory footprints.
- Impose memory limits on resources, including partial loading of resources in memory if possible.
- Avoid solving problems that require unknown memory sizes, which at some point may overflow the capacity given to the app.
Setting the code for Networking
iOS mobile apps use many functions to create network connections, to send and receive data. Apple makes the following recommendations in this regard:
- Define as much as possible the data formats of the protocols used.
- Transmit packets in bursts if possible.
- Avoid protocols that use excessive interaction.
Airplane mode alerts
The application should also consider displaying a WiFi network connection alert, when the device is in airplane mode.
Use of WiFi
If the app uses the WiFi network to connect, it must use iOS keys to tell the system to display the available wifi network selection window, if there is no WiFi connection, and the system must also be told whether or not it can turn off the WiFi hardware, while the App is running.
2. Improving archive management
It is recommended to minimize the amount of writing to disk. For this reason it is recommended:
- Group modified content, to minimize the number of write blocks to disk.
- Write to disk only the portion of the file that changes.
- If the data is structured, it is better to use an internal database, such as Core Data or SQLite.
- It is also recommended to avoid writing cache files to disk.
3. Execution of backup copies
It is recommended to make backup copies efficiently, so that large backup operations are very time-consuming and may not be performed as often as expected. Therefore, it is recommended to host the files according to their characteristics, in the directories where the app is stored:
- In the /Documents directory, critical data, which are those that cannot be recreated by the app itself, such as user data, should be stored.
- In the /Library/Application Support directory, files downloaded by the app, which the application can recreate by itself, are stored.
- In the /Library/Caches directory, cache files should be stored.
- In the /tmp directory, temporary files should be stored.
In this way, when an app is automatically synchronized to iCloud or via iTunes, the necessary data is taken into account so that the iOS mobile application can be restored successfully, without taking up so much space.
4. Do not bring complex tasks into the main execution flow
When performing long tasks that may take a long time, you must ensure that the user can continue working by having the tasks run in the background.
If the system detects an application that is blocking the main flow for a long time, it forcefully stops the app, to prevent it from jeopardizing the stability of the device.
These are a series of recommendations made by Apple to create an application that follows some guidelines to be agile, responsive and that uses memory, CPU and battery resources in the best possible way, to give the best user experience.
In subsequent articles we will discuss the design guidelines for iOS mobile applications.
This article is part of the knowledge difussion system of ITSoftware SAS.
If you liked it, please don’t forget to share it on social networks. 😉