Making network requests
To get our app to communicate with the internet, we need to make a few changes. By default, in the newer version of the iOS, HTTP network requests that are not secure as HTTPs are blocked unless we explicitly tell them to allow it. Since we will be making network requests to our Vapor app, which is running locally as HTTP and not HTTPs, we need to set this in the Info.plist
file of the iOS project. We will also add one more configuration to store the base URL of our Vapor server in this Info.plist
, so we can reference it from one place.
Network configuration
To add the previously mentioned two configurations, we need to follow these steps:
- Open the
Info.plist
file and click on the small+
icon that appears when you hover over theInformation Property List
toward the top of this file: - This will create a new entry in this property list file. Type
NSAppTransportSecurity
and press Enter. This will change the text toApp Transport Security Settings
: - Hover over the
App Transport...