Latest 1.6.2
Homepage https://github.com/Kofktu/Sniffer
License MIT
Platforms ios 8.0, osx 10.9, watchos 2.0, tvos 9.0, requires ARC
Frameworks Foundation
Authors

Build Status
Swift
CocoaPods
Carthage compatible

  • Automatic networking activity logger
  • intercepting any outgoing requests and incoming responses for debugging purposes.

alt tag

Requirements

  • iOS 8.0+, macOS 10.9+, watchOS 2.0+, tvOS 9.0+
  • Swift 4.2
  • Swift 4.0 (1.5.0)
  • Swift 3.0 (1.0.6)

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

CocoaPods

Sniffer is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "Sniffer"

Carthage

For iOS 8+ projects with Carthage

github "Kofktu/Sniffer"

Usage

for any requests you make via ‘URLSession’

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
  Sniffer.register() // Register Sniffer to log all requests
  return true
}

for URLSessionConfiguration

let configuration = URLSessionConfiguration.default
Sniffer.enable(in: configuration)

for Custom Deserializer

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"])

If you want to process the logs directly in your application

// Register the handler if you want the log to be handled directly by the application
Sniffer.onLogger = { (log) in
  print(log)
}

References

Authors

Taeun Kim (kofktu), [email protected]

License

Sniffer is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "Sniffer",
    "version": "1.6.2",
    "summary": "Automatic network activity logger for Swift",
    "homepage": "https://github.com/Kofktu/Sniffer",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Kofktu": "[email protected]"
    },
    "platforms": {
        "ios": "8.0",
        "osx": "10.9",
        "watchos": "2.0",
        "tvos": "9.0"
    },
    "source": {
        "git": "https://github.com/Kofktu/Sniffer.git",
        "tag": "1.6.2"
    },
    "source_files": "Sniffer/Classes/**/*.{swift}",
    "frameworks": "Foundation",
    "ios": {
        "frameworks": "UIKit"
    },
    "watchos": {
        "frameworks": "UIKit"
    },
    "tvos": {
        "frameworks": "UIKit"
    },
    "osx": {
        "frameworks": "AppKit"
    },
    "requires_arc": true
}

Pin It on Pinterest

Share This