Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print to console from application extension

I've been playing around with the new custom keyboard application extension API in iOS 8, using Swift as my language of choice. One thing I've noticed, however, is that println doesn't seem to ever print any output to the console, presumably because those statements are being executed in an application extension rather than the containing app. Has anyone found a way to print statements to the console from within an application extension?

like image 503
Kamaros Avatar asked Jun 29 '14 21:06

Kamaros


2 Answers

Your most reliable choice is to use NSLog for debugging purposes, but println might actually be working in this case. You just need to attach the Xcode debugger to the extension itself.

In my experience, it's a rather buggy process. This answer has more info on the subject. In short, you need to change the target in the Run drop down to your extension, then after you click run you should get a list of things you can run it in.

like image 127
Undo Avatar answered Sep 27 '22 20:09

Undo


As of iOS 10, extensions don't log to console by default. To enable console logging for your extension:

  • Select your extension target in the Xcode target popup
  • Select Product menu > Scheme > Edit Scheme (or Cmd <)
  • In the Run phase under environment variables, add name:OS_ACTIVITY_MODE value: disable
like image 29
John Scalo Avatar answered Sep 27 '22 19:09

John Scalo