The resource could not be loaded because the App Transport Security policy requires the use of a secure connection

前端 未结 21 1717
醉酒成梦
醉酒成梦 2020-11-22 11:37

I am facing the Problem when I have updated my Xcode to 7.0 or iOS 9.0. Somehow it started giving me the Titled error

\"The resource could not be load

相关标签:
21条回答
  • 2020-11-22 12:22

    If you are using Xcode 8.0 and swift 3.0 or 2.2

    0 讨论(0)
  • 2020-11-22 12:23

    In Swift 4 You can use

    ->Go Info.plist

    -> Click plus of Information properties list

    ->Add App Transport Security Settings as dictionary

    -> Click Plus icon App Transport Security Settings

    -> Add Allow Arbitrary Loads set YES

    Bellow image look like

    0 讨论(0)
  • 2020-11-22 12:27

    You just need to use HTTPS and not HTTP in your URL and it will work

    0 讨论(0)
  • 2020-11-22 12:27

    If you are using Xcode 8.0 to 8.3.3 and swift 2.2 to 3.0

    In my case need to change in URL http:// to https:// (if not working then try)

    Add an App Transport Security Setting: Dictionary.
    Add a NSAppTransportSecurity: Dictionary.
    Add a NSExceptionDomains: Dictionary.
    Add a yourdomain.com: Dictionary.  (Ex: stackoverflow.com)
    
    Add Subkey named " NSIncludesSubdomains" as Boolean: YES
    Add Subkey named " NSExceptionAllowsInsecureHTTPLoads" as Boolean: YES
    

    0 讨论(0)
  • 2020-11-22 12:27

    If you use firebase, it will add NSAllowsArbitraryLoadsInWebContent = true in the NSAppTransportSecurity section, and NSAllowsArbitraryLoads = true will not work

    0 讨论(0)
  • 2020-11-22 12:29

    I have solved it with adding some key in info.plist. The steps I followed are:

    1. Opened my Project target's info.plist file

    2. Added a Key called NSAppTransportSecurity as a Dictionary.

    3. Added a Subkey called NSAllowsArbitraryLoads as Boolean and set its value to YES as like following image.

    Clean the Project and Now Everything is Running fine as like before.

    Ref Link: https://stackoverflow.com/a/32609970

    EDIT: OR In source code of info.plist file we can add that:

    <key>NSAppTransportSecurity</key>
        <dict>
            <key>NSAllowsArbitraryLoads</key>
            <true/>
            <key>NSExceptionDomains</key>
            <dict>
                <key>yourdomain.com</key>
                <dict>
                    <key>NSIncludesSubdomains</key>
                    <true/>
                    <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
                    <false/>
                </dict>
           </dict>
      </dict>
    
    0 讨论(0)
提交回复
热议问题