iosloggingswift4oslog

os_log - use of unresolved identifier error


I'm trying to use the new os_log API, by logging a simple statement: os_log("Hello")

And I get an error for os_log: Use of unresolved identifier 'os_log'

I also tried wrapping it in a block, like this

if #available(iOS 10.0, *) {
    let foo: StaticString = "Something happened."
    os_log(foo)
}

And I still get the same error. I would like to use this in Swift 4.

I looked for possible frameworks that might be required, and found no likely candidates.

I found no solution from these links either:

https://developer.apple.com/documentation/os/logging

https://developer.apple.com/videos/play/wwdc2016/721/


Solution

  • Because you forgot to

    import os 
    

    at the start of this file.