Send data over HTTP in iOS Simulator

Published by Tobias Hofmann on

2 min read

You cannot simply send data to a HTTP server in your iOS app. Apple enforces the use of HTTPS and TLS. Therefore, plain HTTP isn’t possible anymore. If you try this in your app to test a local HTTP server, the request will be blocked. In the log you can see this error message:

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.

Cannot start load of Task <F72AD5D0-B8F3-42F3-B959-8FCC1EECF38B>.<1> since it does not conform to ATS policy

Task <F72AD5D0-B8F3-42F3-B959-8FCC1EECF38B>.<1> finished with error – code: -1022

While it is very good that Apple enforces HTTPS, it also creates a small problem for app developers. Either you set up your development environment to support HTTPS and TLS. Or you do have a problem. This problem can be solved by disabling the enforcement of HTTPS for developers.

Add an entry in the Info.plist file of the project. Add an exception to the App Transport Security Settings.

At the bottom of the entries, click on the + icon and select App Transport Security Settings. After the entry is added, click on the + item that appears on the item to add an additional parameter: Allow Arbitrary Loads. This is a Boolean value, and to allow iOS to connect to a HTTP service without security, set its value to YES.

That’s it. Now you can access from your iOS Simulator your developer HTTP server.

Let the world know
Categories: Technology

Tobias Hofmann

Doing stuff with SAP since 1998. Open, web, UX, cloud. I am not a Basis guy, but very knowledgeable about Basis stuff, as it's the foundation of everything I do (DevOps). Performance is king, and unit tests is something I actually do. Developing HTML5 apps when HTML5 wasn't around. HCP/SCP user since 2012, NetWeaver since 2002, ABAP since 1998.

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.