An iOS library to check and share network log easier Easyly embedded into iOS applications
![]() |
![]() |
![]() |
![]() |
![]() |
---|
To integrate Sauron
into your Xcode using Swift Package Manager, add it to the dependencies of Package.swift
dependencies: [
.package(url: "https://github.com/volatilegg/Sauron.git", .upToNextMajor(from: "1.0"))
]
To integrate Sauron
into your Xcode using Cocoapod, add it to your Podfile
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '13.0'
use_frameworks!
target '<Your Target Name>' do
pod 'Sauron', '~> 1.0.0'
end
Using Reqres.defaultSessionConfiguration
as URLSession.configuration
let url = URL(string: "https://pokeapi.co/api/v2/pokemon/108")!
let urlSessionConfig = Reqres.defaultSessionConfiguration(
additionalHeaders: ["Content-Type":"application/json; charset=UTF-8"],
additionalHeaders: 40,
timeoutIntervalForResource: 40,
requestCachePolicy: .useProtocolCachePolicy
)
let urlSession = URLSession(configuration: config, delegate: nil, delegateQueue: nil)
urlSession.dataTask(
with: url,
completionHandler: { (data, response, error) in
// handling response callback
}
)
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
}
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
Open this view RequestListPresentView()
to see the whole log UI
NavigationLink(destination: RequestListPresentView()) {
Text("Open Log")
}
Open this view RequestsListViewController
to see the whole log UI
viewController.show(RequestsListViewController.makeViewController())