SwiftUI + OSlog breaks previews in Swift 6

import SwiftUI
import OsLog

let logger = Logger(subsystem: "Test", category: "Test")

struct ContentView: View {
    var body: some View {
        VStack {
            Image(systemName: "globe")
                .imageScale(.large)
                .foregroundStyle(.tint)
            Text("Hello, world!")
        }
        .padding()
        .task {
            logger.info("Hallo")
        }
    }
}

#Preview {
    ContentView()
}
    27 |         .padding()
    28 |         .task {
    29 |             logger.info(__designTimeString("#6734_2", fallback: "Hallo"))
       |                         `- error: argument must be a string interpolation
    30 |         }
    31 |     }

Should OsLog be compatible with __designTimeString?

Can you post more info about how you reproduced this?

For context, I tried this here in my office and didn’t encounter a problem. Specifically:

  1. Using Xcode 16.2 on macOS 15.3.2, I created a new project from the Multiplatform > App template.

  2. I replaced ContentView.swift with the code you posted.

  3. I changed OsLog (which looks like a typo for the OSLog framework) to os.log, which is the correct way to import Logger.

  4. I selected My Mac as the run destination.

  5. I resumed the preview and everything looked fine.

my Mac

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

SwiftUI + OSlog breaks previews in Swift 6
 
 
Q