Wormholy Documentation

repository·master·Indexed 25 days ago

https://github.com/pmusolino/wormholy

An iOS debugging tool for inspecting network traffic (requests, responses, and headers) via a shake gesture. It works with NSURLSession, Alamofire, and AFNetworking without requiring SSL certificate handling. Supports iOS 16.0+ (or 1.7.x for older versions), Xcode 15+, and Swift 5.

Tokens
702
Snippets
4
Records
5
Agent score
33%

What's inside Wormholy

  1. Install Wormholy

    master

    Wormholy can be integrated using CocoaPods or Swift Package Manager. It is highly recommended to install it only in Debug mode and remove it before production.

    To install via CocoaPods specifically for Debug configurations, add the following to your Podfile:

    pod 'Wormholy', :configurations => ['Debug']
  2. Configure Wormholy settings

    master

    You can customize Wormholy's behavior using several static properties on the Wormholy class:

    • Wormholy.ignoredHosts: An array of host suffixes to exclude from logging (e.g., ["example.com"] ignores example.com and api.example.com).
    • Wormholy.limit: The maximum number of logs to retain in memory.
    • Wormholy.defaultFilter: A string used to set the initial filter in the search box (e.g., "status:500").
    • Wormholy.shakeEnabled: A boolean to enable or disable the shake gesture to trigger the UI.
    • Wormholy.setEnabled(_:): Enables or disables global tracking for all NSURLSession traffic.
    func configureWormholy() {
      Wormholy.ignoredHosts = ["example.com", "analytics.internal"]
      Wormholy.limit = 200
      Wormholy.defaultFilter = "status:500"
      Wormholy.shakeEnabled = true
    
      // Global tracking for URLSession traffic.
      Wormholy.setEnabled(true)
    }
  3. Trigger Wormholy UI without shake gesture

    master

    If you have disabled the shake gesture (via Wormholy.shakeEnabled = false or the environment variable WORMHOLY_SHAKE_ENABLED = NO), you can trigger the Wormholy interface manually by posting the wormholy_fire notification via NotificationCenter.

    NotificationCenter.default.post(name: NSNotification.Name(rawValue: "wormholy_fire"), object: nil)
  4. Enable or disable Wormholy for specific URLSessionConfigurations

    master

    Wormholy automatically hooks URLSessionConfiguration.default and URLSessionConfiguration.ephemeral. To explicitly override behavior for a specific configuration instance, use Wormholy.setEnabled(_:sessionConfiguration:) before creating the URLSession.

    let configuration = URLSessionConfiguration.ephemeral
    Wormholy.setEnabled(false, sessionConfiguration: configuration)
    let session = URLSession(configuration: configuration)