Skip to main content

Setup iOS

Requirements

  • The minimun compatible iOS Version for LogDog is iOS 16
  • LogDog can be used on other platforms (iPad, TV, Apple Vision) but we don't run test on these platforms

Cocoa Package Manager

Add LogDog to your PodFile.

pod 'LogDogSDK'

To download a a specific version please check our Github

pod install

API Key

  1. Create an account at client.logdog.app
  2. Copy your API key from the project settings

Initialize LogDog

Add the following code to your AppDelegate.swift:

import LogDog

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
LogDog.initialize()
let config = LogDogConfig(apiKey: "YOUR_API_KEY", logs: true, network: true, events: true)
LogDog.start(config: config)
LogDog.i("Hello from LogDog")
return true
}
}

Or if you're using SwiftUI, add it to your app's main struct:

import SwiftUI
import LogDog

@main
struct YourApp: App {
init() {
LogDog.initialize()
let config = LogDogConfig(apiKey: "YOUR_API_KEY", logs: true, network: true, events: true)
LogDog.start(config: config)
LogDog.i("Hello from LogDog")
}

var body: some Scene {
WindowGroup {
ContentView()
}
}
}

After launching the app the LogDog SDK will automatically create a new device for your account.

LogDog Devices

Verification

To verify that LogDog is properly installed and configured:

  1. Place a log statement like LogDog.i("Hello from LogDog!")
  2. Run your app
  3. Check the LogDog dashboard - you should see the log appear immediately

Best Practices

  1. Initialize LogDog as early as possible in your app lifecycle
  2. Use appropriate log levels for different types of information
  3. Add relevant metadata to help with debugging
  4. Handle sensitive information appropriately
  5. Monitor network usage and adjust configuration if needed

Troubleshooting

If you're not seeing logs in the dashboard:

  1. Verify your API key is correct
  2. Check that LogDog.initialize() has been called
  3. Ensure you have network connectivity on your desktop and your mobile device
  4. Check if any logs are being filtered by your configuration

Available Methods

Setup and Configuration

// Initialize LogDog with your API key
let config = LogDogConfig(apiKey:"YOUR_API_KEY", logs: true, network: true, events: true)
LogDog.start(config:config)

// Set custom device name
LogDog.setCustomDeviceName(name: "iPhone 15 Pro Test Device")

// Check if LogDog is enabled
LogDog.isEnabled() -> Bool

Logging

Basic logging with LogDog

LogDog.l("Message")
LogDog.i("Info message")
LogDog.w("Warning message")
LogDog.e("Error message")

More advanced logging with the LogDog Logger.

 let logger = LogDogLogger(subsystem: "com.yourcompany.app", category: "main")
logger.l("Log Msg")
logger.i("Info Log Msg")
logger.d("Debug Log Msg")
logger.w("Warning Log Msg")
logger.e("Error Log Msg")
logger.n("Notice Log Msg")
logger.t("Trace Log Msg")
logger.c("Critical Log Msg")
logger.f("Fault Log Msg")

You can use both logging techniques individually or combined. The LogDogLogger uses the swift Logger behind the scenes and offers more features to filter your requests later on.

Event Tracking

// Send custom event
LogDog.logEvent(name: "SETTING_CHANGED", category: "GENERAL", payload: ["user-id":"1"])

Debug Options

// Enable/disable shake to toggle debug window in production builds; Is active by default
LogDog.setDebugShake(active: false)

// Get SDK version
LogDog.getVersion(): String

// Delete device ID
LogDog.deleteDeviceId()

We recommend to deactivate LogDog in store builds and then activate upon request. One easy way to achieve this are universal links (also known as deeplinks). You can enable them by opening your target in XCode and then go to "Signing & Capabilities". Then scroll down to "Associated Domains" and add the following entry:

applinks:open.logdog.app

LogDog Dashboard

To handle a clicked universal link the following lines are required:

With SwiftUI:

 var body: some Scene {
WindowGroup {
ContentView()
.onOpenURL { url in
if url.path == "/start-log-dog" {
LogDog.initialize()
let config = LogDogConfig(apiKey: "YOUR_API_KEY", logs: true, network: true, events: true)
LogDog.start(config: config)
}
}
}
}

With UIKit:

func application(_ application: UIApplication,
continue userActivity: NSUserActivity,
restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
if userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let url = userActivity.webpageURL {
if url.path == "/start-log-dog" {
LogDog.initialize()
let config = LogDogConfig(apiKey: "YOUR_API_KEY", logs: true, network: true, events: true)
LogDog.start(config: config)
}
}
return true
}

You can then share the link: open.logdog.app/start-log-dog with a user seeking support. Feel free to change the path or domain to something custom. Please note that a custom domain requires additional steps to get the universal link working.

To find out more on universal links please check here

Tip: You can also pass a custom device name like open.logdog.app/start-log-dog?device-name=User123 with the universal link. This will then later enable you to assign a memorable name for the device in LogDog.

LogDog.setCustomDeviceName(name: "User123")

Support

If you have questions send us an email via hello@logdog.app. We are happy to help!