您是否觉得调试网络请求和响应很繁琐?如果您没有合适的工具,那确实如此。Guppy 是一个专注于 HTTP 请求的日志记录工具,可以轻松地集成到任何 iOS 应用程序中。 Guppy 将拦截并记录从应用程序发送的每个网络请求。您可以访问任何 Guppy 日志,并毫不费力地与您的团队的其他成员分享。
在模拟器中,您可以使用:^ + ⌘ + z
来调出 Guppy,或者摇动您的手机。
您可以深入挖掘您的网络日志的详细信息,并与您的团队或您自己分享它们。
要运行示例项目,请克隆存储库,并首先从 Example 目录运行 pod install
。
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Guppy.registerURLProtocol()
return true
}
}
class Session: URLSession {
init() {
let configuration = URLSessionConfiguration.default
configuration.urlCache = nil
// Protocols are evaluated in reverse order
// If GuppyURLProtocol is not the last protocol it is not guaranteed to be executed
configuration.protocolClasses = [MyCustomProtocol, GuppyURLProtocol.self]
super.init(configuration: configuration)
}
}
class SessionManager: Alamofire.SessionManager {
init() {
let configuration = URLSessionConfiguration.default
configuration.urlCache = nil
configuration.protocolClasses = [GuppyURLProtocol.self]
super.init(configuration: configuration)
}
}
Guppy 最适合在非生产环境中使用。默认情况下,安装 Guppy 框架会自动在用户摇动设备时使其可用。为了避免这种情况,请执行以下任意组合
didFinishLaunchingWithOptions
中设置 Guppy.shared.showOnShake = false
,用于 Guppy 不应可用的特定时间https://github.com/johnsonandjohnson/Guppy-iOS.git
pod 'Guppy'
github "johnsonandjohnson/Guppy-iOS"
Guppy 在 Apache 2.0 许可下发布。有关详细信息,请参见 LICENSE。