DTNetworkMonitor is a lightweight framework for monitoring network activity in your iOS applications. It provides an easy way to intercept and log network requests and responses made through URLSession
.
- Easy integration with Swift and Objective-C projects.
- Automatic interception of all
URLSession
data tasks, upload tasks, and download tasks. - Detailed logging of network requests and responses.
- iOS 13.0+
- Xcode 11+
- Swift 5.1+
Currently, you can integrate DTNetworkMonitor into your project manually.
- Clone or download the DTNetworkMonitor repository.
- Drag and drop the
DTNetworkMonitor.xcodeproj
into your project or workspace. - Go to your project settings under
General
, scroll down toEmbedded Binaries
, and addDTNetworkMonitor.framework
. - Make sure to
import DTNetworkMonitor
in any file you'd like to use the framework.
- Add DTNetworkMonitor repo to list of packages in Package Dependencies tab in project settings
To use DTNetworkMonitor in a Swift project, you need to initialize and start the monitoring process, typically in your AppDelegate
.
import UIKit
import DTNetworkMonitor
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Start network monitoring
DTNetworkMonitorConfiguration.shared.startMonitoring()
return true
}
}
Objective-C Project For an Objective-C project, you need to import the DTNetworkMonitor module in your AppDelegate and start the monitoring process.
#import <UIKit/UIKit.h>
@import DTNetworkMonitor;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Start network monitoring
[[DTNetworkMonitorConfiguration shared] startMonitoring];
return YES;
}
@end
- Add swiftlint
- Add supprt to distribute through Cocoapods and carthage
- Add more tests