Craig Watkinson
Craig Watkinson

Reputation: 913

NSAppTransportSecurity option not listed in Xcode plist editor

I am trying to add the App Transport Security keys to my Info.plist as described in the following Apple tech note https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/#//apple_ref/doc/uid/TP40016240-CH1-SW3 (Exclusions section)

When I edit the Info.plist file, I did the following:

  1. Click on the '+' next to 'Information Property List' to create a new top level key
  2. Clicked the dropdown to select "NSAppTransportSecurity'

However Xcode doesn't list the option in the drop down list (screenshot below).

Do I need to open the Info.plist file in a text editor and edit this manually?! Or am I missing some (probably obvious!) step?

I'm using Xcode 7.0.1

Thanks

enter image description here

Upvotes: 3

Views: 5444

Answers (2)

J.Williams
J.Williams

Reputation: 1425

Simply it is not already present in Xcode 7.0

You can use anyway Xcode but I suggest you to open the plist file with a text editor and add this to allow all connections to all domains:

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <!-- .......................... -->
        <!-- Other keys already present -->
        <!-- .......................... -->

        <key>NSAppTransportSecurity</key>
        <dict>

           <key>NSAllowsArbitraryLoads</key>
           <true/>

        </dict>

    </dict>
    </plist>

To add specific exceptions to a list of domains add this instead:

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <!-- .......................... -->
    <!-- Other keys already present -->
    <!-- .......................... -->

    <key>NSAppTransportSecurity</key>
    <dict>

        <key>NSExceptionDomains</key>
        <dict>

            <key>domain.com</key>
            <dict>
                <key>NSExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSIncludesSubdomains</key>
                <true/>
            </dict>

        </dict>
    </dict>

</dict>
</plist>

NSIncludesSubdomains is not necessary but permits to access subdomains like wiki.domain.com, blog.domain.com etc.

For a detailed tutorial have a look at this blog post

Upvotes: 3

Felix
Felix

Reputation: 35384

Xcode 7.1 lists the option in the dropdown (App Transport Security Settings). In earlier versions you need to type the raw key NSAppTransportSecurity and set the type to dictionary.

Upvotes: 4

Related Questions