Inject Reqres.defaultSessionConfiguration into Alamofire.Session(configuration:{{configuration}})
let urlSessionConfig = Reqres.defaultSessionConfiguration(
additionalHeaders: ["Content-Type":"application/json; charset=UTF-8"],
additionalHeaders: 40,
timeoutIntervalForResource: 40,
requestCachePolicy: .useProtocolCachePolicy
)
// Usage for Alamofire
let sessionManager = Alamofire.Session(configuration: urlSessionConfig)
// Usage for Moya
var provider = MoyaProvider<PokemonAPI>(
endpointClosure: endpointClosure,
session: sessionManager,
plugins: []
)
provider.request(target) { result in
// handling response callback
}
2. Configure log mode
Note default mode is disabled and should be the mode to use in prodution
Using this snippet to control the mode
// Display all network information
Sauron.shared.logMode = .enable
// Remove all network information
Sauron.shared.logMode = .disable
// Display network information without request's headers
Sauron.shared.logMode = .disableHeader
3. Configure log UI
SwiftUI
Open this view RequestListPresentView() to see the whole log UI
Sauron
An iOS library to check and share network log easier, can be embedded into your iOS app easily
Insprised by Reqres and Wormhole
Installation
Swift Package Manager
To integrate
Sauroninto your Xcode using Swift Package Manager, add it to the dependencies ofPackage.swiftCocoapods
To integrate
Sauroninto your Xcode using Cocoapod, add it to yourPodfileUsage
1. Network configuration
Default network config
Using
Reqres.defaultSessionConfigurationasURLSession.configurationAlamofire/Moya
Inject
Reqres.defaultSessionConfigurationintoAlamofire.Session(configuration:{{configuration}})2. Configure log mode
Note default mode is
disabledand should be the mode to use in produtionUsing this snippet to control the mode
3. Configure log UI
SwiftUI
Open this view
RequestListPresentView()to see the whole log UIUIKit
Open this view
RequestsListViewControllerto see the whole log UI