Introducing NetworkSpectator#
I’m excited to share NetworkSpectator - a lightweight, completely free and open-source Swift library that brings network monitoring and intercepting capabilities to your iOS and macOS apps.
Why I Built This#
After years of iOS development, I found myself repeatedly solving the same problems:
- Debugging API responses during development
- Testing different scenarios without backend changes
- Sharing network logs with QA teams
- Enabling testers to validate business logic independently
Features#
Real-Time Network Monitoring#
Watch every HTTP request and response as it happens:
- Complete request/response details (URL, method, headers, body)
- Response times and status codes
- Beautiful SwiftUI interface for both iOS and macOS
- Analytics dashboard with visual charts for HTTP methods, status codes, and host distribution
Smart Filtering & Search#
Find what you need instantly:
- Filter by HTTP method (GET, POST, PUT, DELETE, etc.)
- Filter by status code (2xx, 3xx, 4xx, 5xx)
- Search requests by URL
- Clean interface that works seamlessly on both platforms
Export in Multiple Formats#
Share logs however your team prefers:
- CSV - Good for spreadsheet analysis
- Plain Text - Simple format for quick sharing
- Postman Collection - Import directly into Postman for API testing
Mocking System#
Test any scenario without backend changes:
Programmatic Mocking - Add mocks in code for reliable unit tests
UI-Based Mocking - Let QA testers create and edit mocks directly from the UI, without Xcode or developer intervention. This means:
- Testers can validate business logic independently
- Faster iteration on edge cases
- Perfect for offline development
Skip Logging for Sensitive Requests#
Keep logs clean and secure:
- Define skip rules programmatically or via UI
- Exclude sensitive or irrelevant requests
- Edit rules on the fly without code changes
Built with Modern Swift#
Being passionate about modern Swift, I built NetworkSpectator using the latest Apple technologies:
- SwiftUI for native, declarative UI on iOS and macOS
- Structured Concurrency (async/await) for safe networking code
- Swift 6
- Tested using Apple’s new Testing framework
- No dependencies - pure, maintainable Swift code
Why Choose NetworkSpectator?#
🟢 Free & Open Source#
The full source code is available under the MIT license.
🟢 No External Dependencies#
Pure Swift. No third-party SDKs to manage.
🟢 Works with SwiftUI and UIKit/AppKit#
Whether you’re building modern SwiftUI apps or maintaining UIKit/AppKit projects, NetworkSpectator integrates seamlessly.
🟢 Empowers Your Entire Team#
Not just for developers:
- QA engineers can inspect requests and create mocks via UI
- Product managers can see actual API responses
- Backend teams can reproduce issues with exported logs
For Developers#
- Debug API integration issues in real-time
- Test scenarios with mocks
- Share detailed logs with backend teams
- Develop features without backend deployment
- Write unit tests for services using mocks without actually making a network request
For QA Engineers#
- Create test scenarios independently via UI mocking
- Export logs as evidence for bug reports
- Validate business logic across different API responses
- No Xcode or coding knowledge required
Get Started Today#
Installation#
Add NetworkSpectator via Swift Package Manager:
https://github.com/Pankajbawane/NetworkSpectator.gitOne-Line Setup#
Add NetworkSpectator via Swift Package Manager and initialize it:
import NetworkSpectator
@main
struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.task {
#if DEBUG
NetworkSpectator.start()
#endif
}
}
}
}That’s it. One line of code, and you’re monitoring all HTTP traffic in your app.
Example Project#
Check out the example app to see it in action: NetworkSpectatorExample
Links#
- GitHub Repository: NetworkSpectator
- Example App: NetworkSpectatorExample
- Connect with me: LinkedIn | GitHub
What’s Next?#
I’m actively developing NetworkSpectator. If you find it useful, consider:
- ⭐ Starring the repo on GitHub
- 📣 Sharing it with fellow developers
- 🐛 Reporting issues or suggesting features
Happy coding! 🚀