Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Blog Reader iPhone App Getting Data from the Web Downloading and Parsing JSON Data

Laura Kirby
Laura Kirby
1,814 Points

2015-09-18 22:04:56.167 Security has blocked a cleartext HTTP (http://) esource load since...

2015-09-18 22:04:56.167 MyBlogReader[16021:2088814] App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file. 2015-09-18 22:04:56.178 MyBlogReader[16021:2088731] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'data parameter is nil'

I have looked around online for a solution to this. Forums are stating that I need to edit the Info.plist. Is this correct? I don't know how to access the source code of this file, I only see autofill options.

https://forums.developer.apple.com/thread/4988

5 Answers

Pablo Alfaro
PLUS
Pablo Alfaro
Courses Plus Student 6,923 Points

Add this line to your Info.plist file alt text click the + symbol to add the new item "NSAppTransportSecurity" and set its type to 'dictionary'. Then select the new line and click the + symbol to add the "NSAllowsArbitraryLoads" into the NSAppTransportSecurity dictionary.

I don't see NSAppTransportSecurity in Info.plist. IOS9 removed it?

Peter Pult
Peter Pult
8,095 Points

Note that the given answers are discouraged. Because setting NSAllowsArbitraryLoads to true will allow all insecure (http://) connections opening your app to threats. See the answers on Stackoverflow for more information.. Basically what the answers says is make an exception for each domain you want to allow with the following XML-Code inside your info.plist file.

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSExceptionDomains</key>
  <dict>
    <key>yourserver.com</key>
    <dict>
      <!--Include to allow subdomains-->
      <key>NSIncludesSubdomains</key>
      <true/>
      <!--Include to allow HTTP requests-->
      <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
      <true/>
      <!--Include to specify minimum TLS version-->
      <key>NSTemporaryExceptionMinimumTLSVersion</key>
      <string>TLSv1.1</string>
    </dict>
  </dict>
</dict>

To see and edit the source code of the info.plist file choose right click -> 'Open As' -> 'Source Code' in your project navigator.

Wilson MuƱoz
Wilson MuƱoz
16,913 Points

Thanks Peter Seems that this is the best approach.

Laura Kirby
Laura Kirby
1,814 Points

Awesome, this fixed the issue. Thank you so much Pablo! (I watched the entire WWDC video on this and still couldn't make it work. )

Laura Kirby
Laura Kirby
1,814 Points

I just noticed your second comment. If you click on the "+" on any item, you can manually add an item to the Info.plist and the then type in specifications you listed about. These items do not autocomplete; however, once you add it in the request works.

Kuan Chung Chang
Kuan Chung Chang
5,607 Points

I have the same issue that I can't find NSAppTransportSecurity in iOS9 info.plist. try to find some website as reference like http://stackoverflow.com/questions/30731785/how-do-i-load-an-http-url-with-app-transport-security-enabled-in-ios-9 but still can't fix the problem.

Thanks Simon a lot! Finally solve this problem :)

Under the project navigator, right click "Info.plist" > Open as > Source code. Then, copy this:

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

Paste it in with the other keys.

Right click "Info.plist" > Open as > Property list. You should see that NSAppTransportSecurity is effectively disabled for this project.