Sources/Pulse/Pulse.docc/Articles/GettingStarted.md
Learn how to integrate Pulse.
https://github.com/kean/Pulse
Add Pulse and PulseUI libraries to your app.
Pulse framework contains APIs for logging, capturing, and mocking network requests, as well as connecting to the Pulse Pro apps.
URLSessionProxy, a thin wrapper on top of URLSession.import Pulse
#if DEBUG
let session: URLSessionProtocol = URLSessionProxy(configuration: .default)
#else
let session: URLSessionProtocol = URLSession(configuration: .default)
#endif
tip: See doc:NetworkLogging-Article for more information about how to configure network logging if your app does not use
URLSessiondirectly, how to further customize it, how to capture and display decoding errors, and more. Pulse is modular and will accommodate almost any system.
import PulseProxy
#if DEBUG
NetworkLogger.enableProxy()
#endif
important: PulseProxy uses method swizzling and private APIs, and it is not recommended that you include it in the production builds of your app. It is also not guaranteed to continue working with new versions of the system SDKs.
To store regular log messages, use LoggerStore.
LoggerStore.shared.storeMessage(
label: "auth",
level: .debug,
message: "Will login user",
metadata: ["userId": .string("uid-1")]
)
tip: Alternatively, you can use it as a SwiftLog backend using PersistentLogHandler from a PulseLogHandler package.
PulseUI allows you to view logs and network requests directly from your app. The framework is centered around a single screen: ConsoleView. On iOS, you can push it into the existing navigation stack or present it modally.
import PulseUI
NavigationLink(destination: ConsoleView()) {
Text("Console")
}
tip: For more information, see the PulseUI documentation.
Pulse also provides separate, indispensable macOS and iOS apps that you can use to view logs collected by the Pulse SDK and even debug your apps in real-time with features like response mocking. The apps are available on the App Store.
The apps require two more simple configuration steps.
Add the following to your app's plist file:
<key>NSLocalNetworkUsageDescription</key>
<string>Network usage required only for development purposes</string>
<key>NSBonjourServices</key>
<array>
<string>_pulse._tcp</string>
</array>
important: Pulse will not show any prompts unless you enable remote logging from the Pulse settings screen.
RemoteLogger/isAutomaticConnectionEnabled:#if DEBUG
RemoteLogger.shared.isAutomaticConnectionEnabled = true
#endif
Once the connection is established, open the Pulse app on your Mac and select the device in the sidebar. The next time you launch the app, the connection will happen automatically.
Learn how to configure Pulse to best suit your app needs in doc:NextSteps and explore additional networking debugging techniques in doc:NetworkLogging-Article.