Skip to content

theCodingDJ/NetTrace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NetTrace

iOS network debugging framework with real-time monitoring, JSON tree viewer, and request inspection.

Features

  • Real-time network monitoring - automatically intercepts all URLSession requests
  • Detailed request/response inspection - headers, body, status codes, timing
  • Interactive JSON tree viewer with expand/collapse
  • Search and filter by URL, method, or status code
  • Copy JSON responses to clipboard
  • Color-coded status indicators
  • Non-intrusive floating button overlay
  • HAR files export functionality to save the list and a single viewed request.

Installation

Swift Package Manager

In Xcode, go to FileAdd Package Dependencies and enter:

https://github.com/theCodingDJ/NetTrace.git

Or add to your Package.swift:

dependencies: [
    .package(url: "https://github.com/theCodingDJ/NetTrace.git", from: "1.1.0")
]

Then add to your target:

.target(
    name: "YourTarget",
    dependencies: ["NetTrace"]
)

Quick Start

Add the following into your AppDelegate:

import NetTrace

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

#if DEBUG
	NetTrace.shared.start()
#endif

	/// Other initialization code here.
	return true
}

HAR Export

NetTrace has the capability to export HAR files to share with backend developers, or view with Charles Proxy/Postman/Proxyman.

Tip

When working with iPhone Simulator, to find your stored .har files open your Terminal, run cd ~/Library/Developer/CoreSimulator/Devices/<Simulator UDID> (you can find your Simulator's UDID in XcodeWindow menuDevices & Simulators), then run the following command in your Terminal: find . -name '*.har'.

Available Functions

NetTrace.shared.start()

Initializes NetTrace and displays the floating overlay button.

#if DEBUG
NetTrace.shared.start()
#endif

NetTrace.shared.show()

Shows the overlay button if previously hidden.

NetTrace.shared.show()

NetTrace.shared.hide()

Hides the overlay button.

NetTrace.shared.hide()

NetRecorder.shared.clear()

Clears all logged requests.

NetRecorder.shared.clear()

NetRecorder.shared.findRequests(where:)

Filters requests using complex logic.

let apiRequests = NetRecorder.shared.findRequests { request in
	request.response?.statusCode == 404 && request.method == "POST"
}

NetRecorder.shared.findRequests(byPath:)

Filters requests by URL path.

let apiRequests = NetRecorder.shared.findRequests(byPath: "/api")

NetRecorder.shared.findRequests(byStatusCode:)

Filters requests by HTTP status code.

let errors = NetRecorder.shared.findRequests(byStatusCode: 404)

NetRecorder.shared.findRequests(byMethod:)

Filters requests by HTTP method.

let postRequests = NetRecorder.shared.findRequests(byMethod: "POST")

License

MIT License

About

NetTrace captures every network request your app performs, provides real-time in-app access to the full log and request details, and supports exporting that data as a HAR file. Inspired by the legendary croozeus/NetLogger.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages