- Automatic networking activity logger
- intercepting any outgoing requests and incoming responses for debugging purposes.
- iOS 8.0+, macOS 10.9+, watchOS 2.0+, tvOS 9.0+
- Swift 5.0
- Swift 4.2 (1.7.0)
- Swift 4.0 (1.5.0)
- Swift 3.0 (1.0.6)
To run the example project, clone the repo, and run pod install
from the Example directory first.
Sniffer is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "Sniffer", '~> 2.0'
For iOS 8+ projects with Carthage
github "Kofktu/Sniffer"
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Sniffer.register() // Register Sniffer to log all requests
return true
}
let configuration = URLSessionConfiguration.default
Sniffer.enable(in: configuration)
public protocol BodyDeserializer {
func deserialize(body: Data) -> String?
}
public final class CustomTextBodyDeserializer: BodyDeserializer {
public func deserialize(body: Data) -> String? {
// customization
return String?
}
}
Sniffer.register(deserializer: CustomTextBodyDeserializer(), for: ["text/plain"])
// Register the handler if you want the log to be handled directly by the application
Sniffer.onLogger = { (url, log) in
print("\(url) : \(log)")
}
Sniffer.ignore(domains: ["github.com"])
- Timberjack (https://github.com/andysmart/Timberjack)
- ResponseDetective (https://github.com/netguru/ResponseDetective)
Taeun Kim (kofktu), kofktu@gmail.com
Sniffer is available under the MIT
license. See the LICENSE
file for more info.