簡體   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