Transport security has blocked a cleartext HTTP
If you are using Xcode 8.0+ and Swift 2.2+ or even Objective C:
If you want to allow HTTP connections to any site, you can use this keys:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
If you know which domains you will connect to add:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>example.com</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
</dict>
</dict>
</dict>
App Transport Security has blocked a cleartext HTTP resource
You need to correct it like this:
To make it easier, this is the correct xml in the info.plist
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSTemporaryExceptionMinimumTLSVersion</key>
<string>TLSv1.1</string>
</dict>
</dict>
</dict>
change the localhost
to your actual server
Check the table for NSAppTransportSecurity options
If you want to all communications with any domain, you can do this:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
However, you should use the latest just in the developing phase.
App transport Security load Error even after adding it
You should add Allow Arbitrary Loads
inside App Transport Security Settings
dictionary, like this:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
iOS swift: App Transport Security has blocked a cleartext HTTP (http://) resource
Seems to be that you are right, that SWAPI supports only the http protocol.
To support also an unsecure connection do this:
- Open the
info.plist
file - Add the Key called
App Transport Security Settings
asDictionary
(Dictionary should be the default type) - Add the Subkey called
Allow Arbitrary Loads
asBoolean
(Boolean should be the default type). Set it toYES
See also the Screenshot:
App Transport Security has blocked a cleartext HTTP Xcode7.1
Open Info.plist and change that text with NSAllowsArbitraryLoads
and your issue will be resolved.
Or open Info.plist file in Source Code mode and replace the following lines:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
Related Topics
How to Prevent Tableview Section Head from Sticking While Scrolling
How to Create Delegates in Objective-C
How to Enable Native Resolution For Apps on Iphone 6 and 6 Plus
Fast and Lean Pdf Viewer For Iphone/Ipad/Ios - Tips and Hints
How to Create a Basic Uibutton Programmatically
Number of Days Between Two Nsdates
How to Detect First Time App Launch on an Iphone
How to Save Picture to Iphone Photo Library
Preferredstatusbarstyle Isn't Called
Creating a Uicollectionview Programmatically
How to Load Image from Local Path iOS Swift (By Path)
Loading/Downloading Image from Url on Swift
How to Use Nsurlconnection to Connect With Ssl For an Untrusted Cert
How to Present Uialertcontroller When Not in a View Controller
How to Make a Clickable Link in an Nsattributedstring