Info.plist : add new capability

One of the lessons on the road to LearnNewStuff was to allow the app to retrieve data from a website that didn’t have SSL (no “https://”, only “http://”) so the traffic between the app and the website isn’t encrypted. Xcode / iOS doesn’t like that – for good reason, but you may have just as good a reason to do it (in this case it’s just a lesson about retrieving web data and isn’t going to be used on a final app).

In order to allow the app to retrieve data from a website via non-encrypted means, we need to add that website to a key titled: “App Transport and Security Settings” – which is in that ever-elusive Info.plist file. As discussed before, enlightened modern thinking by Apple means that this file is no long present in modern versions of Xcode / iOS don’t, so we need to work our way around that.

The Solution

How to add a Domain Exception, in six steps.

Step 1

Click your App name at the top level of the Project Navigator.

Step 2

Click the ‘Signing & Capabilities’ tab.

Step 3

Click the ‘+’ sign at the top-right of the window.

A ‘Capabilities’ window will display.

Step 4

Double-click the ‘App Transport Security Exce…’ option from the list.

You will now see an ‘App Transport Security Exceptions’ box in the ‘Signing & Capabilities’ tab.

Step 5

Click the ‘+’ symbol underneath where it says “Exception Domains”.

Step 6

Double-click “New Exception Domain” and rename it to the domain of the website we wish to retrieve data from – in our case this was “numbersapi.com”.

(press ENTER when done)

Job Done!

We now have an Info.plist file present, with the Exception Domain (in our case “numbersapi.com”) we require listed under “App Transport Security Settings”.