This seems to be in fact working in Beta 1 in the simulator and on device: see the sample below.
Despite being marked as NS_REFINED_FOR_SWIFT you need to call this as described in https://developer.apple.com/documentation/swift/objective-c_and_c_code_customization/improving_objective-c_api_declarations_for_swift
@main
struct LogReaderApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
init() {
do {
os_log("Test message! \(UInt(42), format: .hex)")
let store = try OSLogStore.init(scope: .currentProcessIdentifier)
let position = store.position(date: Date().addingTimeInterval(-3600))
let enumerator = try store.__entriesEnumerator(options: [.reverse], position: position, predicate: nil)
enumerator.forEach { element in
var message = element as? OSLogEntry
dump(message.debugDescription)
dump(message?.composedMessage)
}
} catch {
dump(error)
}
}
}
Topic:
App & System Services
SubTopic:
Core OS
Tags: