Introduction to Xcode

Apr 24 2024 · Swift 5.10, iOS 17, Xcode 15

Lesson 02: Debugging & Troubleshooting in Xcode

Logging Demo

Episode complete

Play next episode

Next

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

In your demo app, first import OSLog and set up a few loggers for different categories. Set them up in the AppMain.swift file so they’ll be visible everywhere in the app.

import OSLog

let movementLogger = Logger(subsystem: "com.example.bragbookapp", category: "movement")
let imageLogger = Logger(subsystem: "com.example.bragbookapp", category: "images")
movementLogger.log("backwards button clicked")
movementLogger.log("forwards button clicked")
imageLogger.log("\(dogImages[currentImage])")
movementLogger.log(level: .error, "forwards button clicked")

imageLogger.log(level: .fault, "\(dogImages[currentImage])")
subsystem: com.example.bragbookapp
See forum comments
Cinema mode Download course materials from Github
Previous: Printing to the Console Next: Conclusion