我正在调试从Internet获取主数据的应用程序中看到的一些不一致的行为。我在模拟器中没有看到问题,只是在设备上,所以我想在模拟器中重现网络和连接环境。
在模拟器中是否有禁用网络的方法?
(我正在远程连接到Mac上编写代码,目前没有其他选择,所以不能禁用操作系统网络)。
我正在调试从Internet获取主数据的应用程序中看到的一些不一致的行为。我在模拟器中没有看到问题,只是在设备上,所以我想在模拟器中重现网络和连接环境。
在模拟器中是否有禁用网络的方法?
(我正在远程连接到Mac上编写代码,目前没有其他选择,所以不能禁用操作系统网络)。
当前回答
您可以禁用主机的网络代替!
其他回答
下载附加工具包(网络链接调节器)
描述
Sierra的例子:
由于Xcode没有提供这样的功能,你肯定会去找一些第三方应用程序/工具。 关闭Mac网络也将有助于关闭iOS模拟器网络。
你可以在系统设置中关闭你的Mac网络连接…→网络并关闭所需的网络源。
关闭你的Mac以太网Internet源:
关闭你的Mac Wi-Fi网络源(如果你的Mac有Wi-Fi网络连接):
你可以使用第三方应用程序(如Charles)限制互联网连接。
在Mac上点击Command + Shift + T设置节流。
有两种方法禁用iOS模拟器的互联网连接:
拔掉网络连接 关闭Wi-Fi
这是最简单的方法。
一个简单的解决方案是为你的Mac创建一个飞行模式。 以下是如何做到这一点:
go into Network in System Preferences click on Location dropdown menu click on plus icon to add a new location name the new location 'Airplane Mode' or similar, and click 'Done' select the location you just created from the Location dropdown menu click on each available network interface in the list at the left of the window in turn, disabling each one click on the Configure iPv4 menu, and choose Off for Wi-Fi, just click on the Turn Wi-Fi Off button click Apply, and this location will block all network activity
当您想重新启动网络时,只需从“位置”下拉菜单中选择“自动”,然后单击“应用”
此解决方案的信誉:http://hints.macworld.com/article.php?story=20130325002258846