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?
Asked
Active
Viewed 6,525 times
10
-
Not sure about from an extension, but you can always try good old fashioned NSLog or make a logging breakpoint in Xcode. – macshome Jun 29 '14 at 23:16
-
possible duplicate of [How to debug iOS 8 extensions with NSLog?](http://stackoverflow.com/questions/24031612/how-to-debug-ios-8-extensions-with-nslog) – Andrew Jul 09 '14 at 03:18
-
I'm having trouble here too even with NSLog. I can step through my extension using the debugger on the simulator fine, but no NSLog messages ever show on the console. I've also tried running the extension and then connecting the debugger to the extension process, but still nothing on the console. – Joey Carson Jul 02 '16 at 16:14
2 Answers
11
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.
8
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

John Scalo
- 3,194
- 1
- 27
- 35
-
2doesn't work for me, I still don't see neither prints nor NSLog's. Could you please let me know which other options I probably need to turn on? – iago849 May 11 '19 at 11:24
-
I'd like to add it doesn't work if I attach the debugger but if I run it directly with the right scheme target it works. – Warpzit Jan 13 '23 at 14:11