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 XCode 7.1
Use NSTemporaryExceptionAllowsInsecureHTTPLoads
instead of NSAllowsArbitraryLoads
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>myDomain.net</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
<key>anotherDomain.com</key>
<dict>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
App access blocked due to App Transport Security has blocked a cleartext HTTP and done almost everything
You need to add this also Allows Arbitrary Loads
Related Topics
Setting Constraints Programmatically
Get Date and Time from Apple Server
iOS 8 Keyboard Hides My Textview
How to Get Managedobjectcontext for Viewcontroller Other Than Getting It from Appdelegate
How to Do Authentication in Uiwebview Properly
Uiwebview Webpage Caching for Offline Viewing
How to Disable Afnetworking Cache
iOS Cllocationmanager in a Separate Class
Converting Nsdictionary Object to Nsdata Object and Vice-Versa
Custom Url to Launch Facebook Messenger on iOS
How to Directly Rotate Cvimagebuffer Image in iOS 4 Without Converting to Uiimage
Using Cabasicanimation to Rotate a Uiimageview More Than Once
Changing View Controller When Segmented Control Changes
How to Properly Order Data from Firebase Chronologically