Home » Ios » iOS 10 doesn't print NSLogs

iOS 10 doesn't print NSLogs

Posted by: admin November 30, 2017 Leave a comment

Questions:

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
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.

Questions:
Answers:

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)

Questions:
Answers:

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

enter image description here
enter image description here

Questions:
Answers:

I can’t see NSLog output in real iOS 10 device neither. If you’re using real devices, you can open Devices window from Xcode (Shift + Command + 2) and see device logs there, but it’s hard to look at your app’s logs because the console shows logs from system and all apps.

(I’m using Xcode 7, so it’s may not Xcode’s problem but iOS 10 problem)

Questions:
Answers:

Hmmm… it seems like the property “OS_ACTIVITY_MODE”: “disable” PREVENTS NSlog from showing up in the Xcode 9 log.

Unchecking this value in my scheme restored my logs.

Questions:
Answers:

Also, make sure the Console is actually visible in Xcode (i.e., make sure the right-hand side icon is highlighted in blue, as per the image below). After I upgraded Xcode it hide the Console and showed me just the Variables view. This made it look like NSLog() was not working properly, whereas it was indeed working correct, I just couldn’t see the output.

enter image description here

Questions:
Answers:

I’m using Xcode 8,so I also encountered the same problem . And I solved this problem by adding value = disable on the simulator, but on a real machine I don’t add value.

Questions:
Answers:

The accepted answer initially gave me a way to display output from NSLog messages but it no longer worked after I upgraded to Xcode 9.1 + iOS 11.1. However I was able to display Debug messages once again by using the Console app by enabling the Simulator (see Lucas’ answer).

In the Console app I selected Include Debug Messages under Product -> Scheme. I also had to deselect Include Info Messages so the Console is not swamped with system messages.