最近为了测试app极端网络环境的反馈结果,在网上找了很多资料,发现大多数关于Network Link Conditioner的使用安装比较旧,安装之后无法起到效果,所以重新整理了一份,建议Network Link Conditioner工具版本号与Xcode版本号保持一致
在Xcode4.1中有一个工具叫Network Link Conditioner,可以让用户模拟不同的网络连接和带宽,可供Mac和iOS开发者测试自己的程序在不同网络环境下的表现。
在Xcode4.3之后,此工具不再随Xcode工具提供,需要单独下载。在Xcode10中通过Xcode->Open Developer Tool->More Developer Tools…菜单

可进入Apple开发者下载中心,Network Link Conditioner包含在Hardware IO Tools中,但在Xcode7.3之后版本Hardware IO 包含在工具Additional Tools包中,点击下载。

下载安装后,可看到其中有一个Hardware,进入后就能见到Network Link Conditioner.prefPane文件。


点击运行Network Link Conditioner.prefPane后,Network Link Conditioner就会被添加到系统偏好设置的其他分类中。


点击打开,Network Link Conditioner界面为

在Profile中包含预置的几种网络环境,包含3G,DSL,Edge,Wifi,每种网络环境对应不同的上下行带宽,丢包率和网络延迟,DNS延迟。

还可以根据需要自定义不同的网络环境,点击左下角锁按钮输入系统密码解锁后,右侧Manage Profiles…就变为可用,点击后可进入管理Profiles窗口,在其中可定义自己需要的Profile.

把ON/OFF按钮滑动到ON,即启动了网络模拟器。

启动Network Link Conditioner就可以使用iOS模拟器测试APP在此种环境下的运行情况了。
在测试完毕时,记得停止Network Link Conditioner,Network Link Conditioners是对整个系统有效的,普通上网的速度也会被限制。
网友评论