Guppy 0.10.0

Guppy 0.10.0

由以下人员维护:Stephen HayesBrandon WaltonDiego Urquiza



Guppy 0.10.0

  • Johnson & Johnson

Guppy

Platform Swift Version CocoaPods Carthage compatible codecov License

想知道什么是繁琐的吗?在没有正确工具的情况下调试网络请求和响应。Guppy是一个关注HTTP请求的日志工具,可以轻松集成到任何iOS应用程序中。Guppy将拦截并记录从应用程序发送的每次网络请求。您可以轻松访问任何Guppy日志并与团队成员共享。

使用

在模拟器中,您可以使用:^ + ⌘ + z调出Guppy或摇动您的手机。

Routes

您可以深入挖掘网络日志的细节,并与您的团队或自己共享。

Details

示例

要运行示例项目,请首先克隆仓库,然后从Example目录运行pod install

URLSession

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
        Guppy.registerURLProtocol()
        
        return true
    }
}

带自定义协议的URLSession

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)
    }
}

Alamofire

class SessionManager: Alamofire.SessionManager {

    init() {
        let configuration = URLSessionConfiguration.default

        configuration.urlCache = nil
        configuration.protocolClasses = [GuppyURLProtocol.self]
        
        super.init(configuration: configuration)
    }
}

需求

  • Xcode 12.0+
  • iOS 13.0+

安装

Guppy最好用于非生产环境。默认情况下,安装Guppy框架将在用户摇晃设备时自动使其可用。为了避免这种情况,执行以下任一组合操作:

  • 如果您正在使用多个目标针对不同的环境,只需将Guppy框架包含在非生产目标中。
  • 如果您正在使用单一目标并对不同环境有多种配置,只需将Guppy框架包含在非生产配置中。
  • 在某些特定时间Guppy不可用的情况下,在您的didFinishLaunchingWithOptions中设置Guppy.shared.showOnShake = false

Swift包管理器

https://github.com/johnsonandjohnson/Guppy-iOS.git

CocoaPods

pod 'Guppy'

Carthage

github "johnsonandjohnson/Guppy-iOS"

许可协议

Guppy在Apache 2.0许可协议下发布。详细信息请参阅许可协议