HTTPProxy
iOS 网络调试工具
特性
- 列出使用默认 URLSessionConfiguration 的 URLSessions 运行的所有 HTTP 和 HTTPS 流量
- 按 URL 搜索请求
- 显示每个请求的详细信息,包括文本搜索
- 检查请求/响应体和头信息
安装
CocoaPods
pod 'HTTPProxy'
设置
首先,在任意请求触发之前(例如在 application(:, didFinishLaunchingWithOptions:)
中)通过调用 HTTPProxy.shared.enable()
来启用 HTTPProxy
import HTTPProxy
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
HTTPProxy.shared.enable()
return true
}
}
然后,您可以在应用的任何地方通过以下代码来可视化请求:
HTTPProxy.shared.presentViewController()
该工具还可以通过摇动手势显示。