NSAllowsArbitraryLoads

Hi! I have problem with webrequests on iOS. Xcode gives me a following error:

You are using download over http. Currently unity adds NSAllowsArbitraryLoads to Info.plist to simplify transition, but it will be removed soon. Please consider updating to https.

Here is the code i’m using for connecting to the http server

public IEnumerator WaitForRequest(String query)
    {
        string URL = "http://server.com/backend?message=" + query;
        UnityWebRequest www =  UnityWebRequest.Get(URL);

        yield return www.Send ();
        if (!www.isError)
        {
            yield return www.downloadHandler.text;
        }
        else {
            yield return "fail";
        }
    }

In the info.plist i have following lines added

<key>NSAppTransportSecurity</key>
    <dict>
        <!--To support localhost -->
        <key>NSAllowsLocalNetworking</key>
        <true/>
        <!--To continue to work for iOS 9 -->
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>

I have tried various fixes i’ve found while searching for answers to this problem, but nothing seems to work.

I’m using Xcode version 8.2.1 and Unity version 5.5.1f1

Can you explain what the actual problem is?

HI @Roistock ,
Please refer to the apple developer forums about app transport security
App Transport Security REQUIRED Ja… | Apple Developer Forums.

The short story is that apple wants developers to use https over http. You can specify exceptions to this rule for your app. In Unity’s case, we automatically set NSAllowsArbitraryLoads for you in your info.plist so you don’t see any problems downloading over http while you are in development. This setting essentially disables App Transport Security. The log you added to your post is a warning to you, the developer, to let you know that this isn’t a real solution and you should either
1.) Get your server authenticated to use https or
2.) Justify to apple the reason you can’t do it when you submit your app for review.

Please let me know if this answers your question, or ask more if you need help.
Cheers,
Chris

1 Like