Adding the background fetch capabilities

Every application has a list of capabilities they can opt in for. Some examples of these capabilities are Maps, Home Kit, and Background Modes. You can find the Capabilities tab in your project settings. If you select your project in the file navigator, you can see the Capabilities tab right next to your app's Delete settings.

If you select this tab, you will see a list of all the capabilities your app can implement. If you expand one of these capabilities, you're informed about what the capability does and what happens automatically if you enable it. If you expand the Background Modes capability, you'll see the following information:

There are several modes available to our app, but we're only interested in one at this time. We want to implement Background fetch. Click on the on/off checkbox to enable this capability for our application, and check the Background fetch option.

Enabling Background fetch isn't something that magically changes some invisible settings for your application. You can actually enable background fetch manually if you'd like to do so.

Open up the Info.plist file and search for the Required background modes key. You can see that it contains a single item with a value of App downloads content from the network. This entry in the Info.plist file enables your app to request iOS to wake it up periodically:

However, just because we can do this manually does not mean we should. The capabilities tab is a very convenient place in which you can manage capabilities, and manually adding the right key to the Info.plist file is tedious and error-prone. It's interesting to know that there's no magic involved in this process, and it makes the entire feature feel more transparent.