The resource could not be loaded because the App Transport Security policy requires the use of a secure connection The resource could not be loaded because the App Transport Security policy requires the use of a secure connection ios ios

The resource could not be loaded because the App Transport Security policy requires the use of a secure connection


I have solved it with adding some key in info.plist.The steps I followed are:

  1. Opened my Project target's info.plist file

  2. Added a Key called NSAppTransportSecurity as a Dictionary.

  3. Added a Subkey called NSAllowsArbitraryLoads as Boolean and set its value to YES as like following image.

enter image description here

Clean the Project and Now Everything is Running fine as like before.

Ref Link: https://stackoverflow.com/a/32609970

EDIT:OR In source code of info.plist file we can add that:

<key>NSAppTransportSecurity</key>    <dict>        <key>NSAllowsArbitraryLoads</key>        <true/>        <key>NSExceptionDomains</key>        <dict>            <key>yourdomain.com</key>            <dict>                <key>NSIncludesSubdomains</key>                <true/>                <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>                <false/>            </dict>       </dict>  </dict>


Be aware, using NSAllowsArbitraryLoads = true in the project's info.plist allows all connection to any server to be insecure. If you want to make sure only a specific domain is accessible through an insecure connection, try this:

enter image description here

Or, as source code:

<key>NSAppTransportSecurity</key><dict>    <key>NSExceptionDomains</key>    <dict>        <key>domain.com</key>        <dict>            <key>NSExceptionAllowsInsecureHTTPLoads</key>            <true/>            <key>NSIncludesSubdomains</key>            <true/>        </dict>    </dict></dict>

Clean & Build project after editing.


Transport security is provided in iOS 9.0 or later, and in OS X v10.11 and later.

So by default only https calls only allowed in apps. To turn off App Transport Security add following lines in info.plist file...

<key>NSAppTransportSecurity</key>  <dict>    <key>NSAllowsArbitraryLoads</key>    <true/>  </dict>

For more info:
https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW33