6

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/

Jens
  • 20,533
  • 11
  • 60
  • 86
Sheamus
  • 6,506
  • 3
  • 35
  • 61

1 Answers1

19

Because you forgot to

import os 

at the start of this file.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • Also that is not how to use `os_log`. See https://stackoverflow.com/questions/53403036/problems-with-unified-logging-staticstring-customstringconvertible-and-descrip for a complete example. – matt Nov 29 '18 at 20:14
  • 1
    For Objective-C, it is `#import `, correct? – joshbodily Jul 12 '19 at 16:29
  • 1
    Probably. I could have said `import os.log` in my answer, which seems to be the same thing. – matt Jul 12 '19 at 16:33