Skip to content

MingHieu/NetInspect

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

📡 NetInspect SDK

NetInspect is a lightweight iOS SDK for monitoring and debugging network requests.


✨ Features

  • Detects current network status (WiFi, Cellular, or None).
  • Monitors connectivity changes with callbacks.
  • Logs all outgoing requests & incoming responses (method, URL, headers, body).
  • UI inspector for viewing logs directly inside your app.

📦 Installation

  1. Download: Locate NetInspect.xcframework in the archive/ directory.
  2. Import: Drag and drop the .xcframework into your Xcode project.
  3. Embed: In your Target's General settings, under Frameworks, Libraries, and Embedded Content, ensure NetInspect.xcframework is set to Embed & Sign.

📚 API Reference

NetworkConnection

Monitors device network connection.

Property / Method Type Description
isConnected Bool Whether device is connected to the internet.
networkType NetworkType Current network type (.wifi, .cellular, .none).
isWiFi Bool Convenience flag for WiFi connection.
isCellular Bool Convenience flag for Cellular connection.
onStatusChange ((Bool, NetworkType) -> Void)? Callback when connection changes.
startMonitoring() Void Starts observing network status.
stopMonitoring() Void Stops observing network status.

NetworkLogger

Logs HTTP/HTTPS requests and responses.

Method Description
start() Starts logging.

🚀 Example Usage

import NetInspect

// MARK: - Network Connection Monitoring
NetworkConnection.startMonitoring()

// Get current status
print("Connected: \(NetworkConnection.isConnected)")
print("Type: \(NetworkConnection.networkType)")

// Listen for changes
NetworkConnection.onStatusChange = { isConnected, type in
    print("📡 Status: \(isConnected ? "Online" : "Offline") via \(type)")
}

// MARK: - Network Logging
#if DEBUG
NetworkLogger.start()
#endif

// Example request
let url = URL(string: "https://jsonplaceholder.typicode.com/posts")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.httpBody = """
{
  "title": "foo",
  "body": "bar",
  "userId": 1
}
""".data(using: .utf8)

URLSession.shared.dataTask(with: request) { data, response, error in
    // NetInspect will log everything automatically
}.resume()

About

NetInspect is a lightweight iOS SDK for monitoring and debugging network requests.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors