xcode 无法在 iOS 模拟器上访问网站——“此连接不是私密的”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46980164/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 10:23:20  来源:igfitidea点击:

Can't visit website on iOS Simulator—'This Connection Is Not Private'

xcodeios-simulator

提问by Hymanchmbrln

I'm currently building a watch app extension and want to use the simulator because it is much easier and quicker than building to my actual Apple Watch every time.

我目前正在构建一个手表应用程序扩展并且想要使用模拟器,因为它比每次构建到我的实际 Apple Watch 更容易和更快。

However, I've run into a problem with the simulator where I can't visit any websites due to the error 'This Connection Is Not Private'. This wouldn't normally be a problem except in my case I need to login into my iOS using Facebook and I face the same problem there. The message is slightly different when using SFSafariViewController:

但是,我遇到了模拟器问题,由于“此连接不是私有的”错误,我无法访问任何网站。这通常不会成为问题,除非在我的情况下,我需要使用 Facebook 登录到我的 iOS 并且我在那里面临同样的问题。使用时消息略有不同SFSafariViewController

  Safari cannot open the page because it could not establish a secure connection to the server

I have looked in the Safari settings on the simulator to see if there's any security that I can disable but have been unable to find anything. Is there any way I can get around this issue?

我查看了模拟器上的 Safari 设置,看看是否有任何可以禁用但找不到任何内容的安全性。有什么办法可以解决这个问题吗?

I'm currently using the Xcode 9.1 and macOS High Sierra 10.13.1

我目前使用的是 Xcode 9.1 和 macOS High Sierra 10.13.1

screenshot

截屏

回答by Joey

It works for me after deleting all anti-virusprograms from my Mac. Hope it would be helpful for you.

从我的 Mac删除所有防病毒程序后,它对我有用。希望对你有帮助。

回答by Donald Rodriguez

Good morning,

早上好,

I had the same problem with Avast in my Mac. You don't need to delete it, just go to the settings and disable the 'Web Shield' meanwhile you are using the simulator: See image for details

我在 Mac 上使用 Avast 时遇到了同样的问题。您不需要删除它,只需在使用模拟器的同时转到设置并禁用“Web Shield”: 有关详细信息,请参见图片

If you don't want to disable it for all the web sites, you could add the server to the excluded list: See image for details

如果您不想为所有网站禁用它,您可以将服务器添加到排除列表: 有关详细信息,请参见图片

Hope this helps! Regards.

希望这可以帮助!问候。

回答by Caleb

I've run into a problem with the simulator where I can't visit any websites due to the error 'This Connection Is Not Private'.

我遇到了模拟器问题,由于“此连接不是私有的”错误,我无法访问任何网站。

It sounds like you're probably running into App Transport Security, which requires apps to connect to servers securely. In most cases, all you need to do is change the method of the URL you're using from HTTP to HTTPS.

听起来您可能遇到了App Transport Security,它需要应用程序安全地连接到服务器。在大多数情况下,您需要做的就是将您使用的 URL 的方法从 HTTP 更改为 HTTPS。