pbm pbm - 20 days ago 5
iOS Question

How to show all simulator outputs in xcode

I'm using Xcode 8.1 and Simulator 10.0. When I run my app from Xcode on the simulator I can see all print statements from my app appear in the Xcode console. I'm happy!

For testing purposes I kill my App in the simulator by clicking

CMD+SHIFT+H
twice and swiping up on the simulator. This removes it from memory. I now click the app's icon on the simulator to start it again. It runs fine, but the app's print statements are no longer shown on the Xcode console. I've tried to find them in the simulators system log (accessed via Simulator -> Debug -> Open System Log) but cannot find them.

How can I see my app's print statements in this scenario?

Answer

Swift print does not write to the log; it is useful only when speaking to Xcode, if you see what I mean. This is good because it keeps print statements from cluttering up the user's device logs. Instead of print, use NSLog. Your logging will then be written to the simulator's system log.