Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 10 doesn't print NSLogs

Nothing prints from NSLog on Xcode 8.0 beta (8S128d). printf is unchanged

Here's my code:

NSLog(@"hello from NSLog");
printf("hello from printf");

Here's the output on iOS 9 Simulator:

2016-06-17 09:49:10.887 calmapp-dev[28517:567025] hello from NSLog
hello from printf

Here's the output on iOS 10 Simulator:

hello from printf
like image 522
Tyler Sheaffer Avatar asked Jun 17 '16 16:06

Tyler Sheaffer


3 Answers

It could be that you added the property "OS_ACTIVITY_MODE": "disable" in the Scheme environment variables (to hide OS output from the simulator) and forgot about it, and now are running on a real device.

In Xcode 8:

Product -> Scheme -> Edit Scheme -> Run -> Arguments -> Environment Variables

Only add OS_ACTIVITY_MODE and check it(Don't add a value)

enter image description here

enter image description here

Summary: This is a bug of Xcode 8 + iOS10, we can solve it in this way:

  • When using the simulator, add the Name "OS_ACTIVITY_MODE" and the Value "disable" and check it.

  • When on a real device, only add "OS_ACTIVITY_MODE" and check it(Don't add the Value). You will see the NSLog in the Xcode8 Console.

like image 146
user6833743 Avatar answered Nov 17 '22 15:11

user6833743


If you check the Xcode 8 beta release notes, you'll find that it says:

When debugging an app running on Simulator, logs may not be visible in the console. Workaround: Use command + / in Simulator.app to open the system log in the Console app to view NSLogs. (26457535)

like image 33
Lucas Avatar answered Nov 17 '22 14:11

Lucas


the NSlog or print actually is executed but is hidden among lots of other console debug outputs to solve this issue Open Xcode8:

Product -> Scheme -> Edit Scheme -> Run -> Arguments -> Environment Variables

add "OS_ACTIVITY_MODE" and set the Value to "disable" and check it.

click close

xcode9

add "OS_ACTIVITY_MODE" and set the Value to "default" and check it.

enter image description here enter image description here

like image 19
MiladiuM Avatar answered Nov 17 '22 13:11

MiladiuM