繁体   English   中英

如何在Mac OS上从iPhone连接到本地主机

[英]how to connect from my iphone to my localhost on my mac os

我读了很多关于它的问题,但仍然有问题。

当我使用localhost并从模拟器中更正NSAppTransportSecurity optinos时,一切都正确。

现在,我正在使用iPhone进行调试。 iPhone和Mac都连接到同一网络。

我检查了我的Mac的IP地址

我将其添加到NSAppTransportSecurity中,如下所示:

  <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>10.250.x.x</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
                <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
                <true/>
                <key>NSTemporaryExceptionMinimumTLSVersion</key>
                <string>TLSv1.1</string>
            </dict>
        </dict>
    </dict>

我仍然收到错误:

 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.
error = Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." UserInfo={NSUnderlyingError=0x7f904d300170 {Error Domain=kCFErrorDomainCFNetwork Code=-1022 "(null)"}, NSErrorFailingURLStringKey=http://10.250.x.x:8080/IVRServer/api/registration/register, NSErrorFailingURLKey=http://10.250.x.x:8080/IVRServer/api/registration/register, NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.}

我应该在我的列表中添加其他内容吗?

请不要考虑重复此问题,因为我已经在我的plist中使用了正确的设置,并且工作正常,但是当我将服务器更改为非本地主机时,它却无法工作

我想念什么?

如果只想绕过此限制,请允许所有负载:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

这应该是可行的,因为大概您正在使用“本地主机”,因此不会有任何安全问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM