Dealing with App Transport Security in Xcode

Xcode iOS Networking

Posted on 12 Apr 2023 . 2 min read


What is App transport security(ATS)?


App transport security improves user security and privacy by making secure connections to network.


When we try to make network requests, a console error has been printed.


App Transport Security has blocked a cleartext HTTP connection since 
it is insecure. Use HTTPS instead or add Exception Domains to your 
app's Info.plist.


It indicates that ATS is blocking insecure connections. You must use HTTPS in the URL to make secure connections or update the Info.plist file with a key that grants a temporary exemption.


The info.plist file is a dictionary of information about an app used while deploying it to the App Store. Adding the ATS exemption key in the info.plist file means we are saying that app might make insecure connections.


Open the info.plist file from the project navigator, and you will see the default set of keys for an app.


Click on "Information Property List" and plus sign (+) will appear. To add a new key to the file, click the plus sign (+). To allow HTTP requests, you have to add the key "App Transport Security Settings".


Image App Transport Security Settings


App Transport Security Security Settings has a dictionary value. Click on the key name, then click on the plus sign (+), and add the key "Allow Arbitrary Loads". The value of this key is a boolean that should be set to "Yes".



Image Allow Arbitrary Loads

The bottom line


While working with network requests, always try to work with a secure HTTPS network. It helps the app perform secure network requests. If your API does not provide a secure connection, then use an exemption key to perform network requests.


Don’t hesitate to contact me if you have any questions or queries. Follow me on twitter @gurjitpt for any updates.

Thanks!


More articles:


Share this article



Written By

Generic placeholder image

Gurjit Singh

I’m Computer Science graduate and an iOS Engineer who writes about Swift and iOS development. Follow me for more updates:


Discover articles by topics

SwiftUI Class Struct Networking XCode NSCache Enum Optionals Property Observers Closures Guard Reviews StoreKit App Store Algorithms Testing Operators Protocol Extensions Weak Unowned SwiftData WWDC23 GCD API Admob SwiftLint Lottie Foreach Objective-C UIKit NavigationSplitView

Related Articles


Connection failed: Access denied for user 'techwyhu'@'server82.web-hosting.com' (using password: YES)