Contents

pmusolino/wormholy

Start debugging iOS network calls like a wizard, without extra code! Wormholy makes debugging quick and reliable.

Requirements

Usage

Integrating Wormholy into your project is simple, and it works like magic! Shake your device or simulator to access Wormholy. There's no need to import the library into your code.

<u>It is recommended to install it only in debug mode and not integrate it into production. Please remove it before sending your apps to production.</u> The easiest way to do this is with CocoaPods:

pod 'Wormholy', :configurations => ['Debug']

You can also integrate Wormholy using the Swift Package Manager!

Configuration Options

  • Ignored Hosts: Specify hosts to be excluded from logging using Wormholy.ignoredHosts. This is useful for ignoring traffic to certain domains.
  • Logging Limit: Control the number of logs retained with Wormholy.limit. This helps manage memory usage by limiting the amount of data stored.
  • Default Filter: Set a default filter for the search box with Wormholy.defaultFilter to streamline your debugging process.
  • Enable/Disable: Use Wormholy.setEnabled(:) to toggle request tracking globally. You can also enable or disable it for specific URLSessionConfiguration instances using Wormholy.setEnabled(:sessionConfiguration:).
  • Shake Gesture: Control the activation of Wormholy via shake gesture with Wormholy.shakeEnabled.
  • Status Check: Use Wormholy.isWormholyEnabled() to inspect whether global Wormholy tracking is currently enabled.

Example Configuration

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)

  // Use the session-specific API when you want to override behavior
  // for a particular configuration instance.
  let configuration = URLSessionConfiguration.default
  Wormholy.setEnabled(false, sessionConfiguration: configuration)

  let session = URLSession(configuration: configuration)
  _ = session
}

Notes on Session Configurations

Wormholy automatically hooks URLSessionConfiguration.default and URLSessionConfiguration.ephemeral.

Use Wormholy.setEnabled(_:sessionConfiguration:) when you want to explicitly enable or disable Wormholy for a specific configuration instance before creating the URLSession:

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

Background sessions are a separate case: Apple does not support custom URLProtocol classes with background URLSessionConfiguration, so Wormholy cannot be injected there via protocolClasses.

Notes on Ignored Hosts

Wormholy.ignoredHosts uses suffix matching on the request host.

For example, if you set:

Wormholy.ignoredHosts = ["example.com"]

Wormholy will ignore requests to both example.com and subdomains such as api.example.com.

Triggering Wormholy

If you prefer not to use the shake gesture, you can disable it using the environment variable WORMHOLY_SHAKE_ENABLED = NO.

To trigger Wormholy manually from another point in your app without using the shake gesture, post the wormholy_fire notification:

NotificationCenter.default.post(name: NSNotification.Name(rawValue: "wormholy_fire"), object: nil)

By following these steps and configurations, you can effectively integrate Wormholy into your development workflow, enhancing your ability to debug network requests efficiently.

Contributing

  • If you need help or you'd like to ask a general question, open an issue.
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Acknowledgements

Made with ❤️ by Paolo Musolino.

Follow me on:

💼 LinkedIn
🤖 X

MIT License

Wormholy is available under the MIT license. See the LICENSE file for more information.

Package Metadata

Repository: pmusolino/wormholy

Default branch: master

README: README.md