伙计们,我创建了一个基于Web视图的ios应用。在启动之前,我必须对其进行测试,但无法在测试应用程序中加载本地主机

我尝试过这种方法

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>192.168.0.189</key>
        <string></string>
        <key>ExceptionAllowsInsecureHTTPLoads</key>
        <true/>
        <key>localhost:port</key>
        <string></string>
    </dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>


还有其他方法吗?

最佳答案

尝试这个!

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSExceptionDomains</key>
    <dict>
        <key>192.168.0.189</key>
        <dict>
        <key>NSIncludesSubdomains</key>
        <true/>
        <key>NSExceptionAllowsInsecureHTTPLoads</key>
        <true/>
        <key>NSExceptionRequiresForwardSecrecy</key>
        <true/>
        <key>NSExceptionMinimumTLSVersion</key>
        <string>TLSv1.2</string>
        <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
        <false/>
        <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
        <true/>
        <key>NSThirdPartyExceptionMinimumTLSVersion</key>
        <string>TLSv1.2</string>
        <key>NSRequiresCertificateTransparency</key>
        <false/>
    </dict>
    </dict>
</dict>

关于swift - 如何快速加载本地主机,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58968232/

10-10 01:32