IOS 10 does not print NSLogs

Nothing is printed from NSLog on Xcode 8.0 beta (8S128d). printf does not change

Here is my code:

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

Here's the output on the 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 
+87
ios xcode ios10 xcode8 nslog
Jun 17 '16 at 16:49
source share
9 answers

Perhaps you added the "OS_ACTIVITY_MODE": "disable" property in the Scheme environment variables (to hide the OS output from the simulator) and forgot about it, and now they work on a real device.

In Xcode 8:

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

Add only OS_ACTIVITY_MODE and check it (do not add value)

enter image description here

enter image description here

Summary: This is an Xcode 8 + iOS10 bug, we can solve it as follows:

  • When using the simulator, add the name "OS_ACTIVITY_MODE" and the value "disable" and check it.

  • If on a real device, add only "OS_ACTIVITY_MODE" and check it (do not add a value). You will see NSLog in the Xcode8 console.

+227
Sep 15 '16 at 5:19
source share

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

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

+27
Jun 17 '16 at 18:36
source share

NSlog or printing is actually running, but hiding among many other console debugging outputs to solve this problem. Open Xcode8:

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

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

to close

xcode9

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

enter image description here enter image description here

+17
Sep 15 '16 at 20:06
source share

I can’t see the NSLog output on a real iOS 10 device. If you use real devices, you can open the Devices window from Xcode (Shift + Command + 2) and look at the device logs there, but it’s difficult for you to view the application logs because Consoles display logs from the system and all applications.

(I use Xcode 7, so this may not be an Xcode problem, but a problem with iOS 10)

+7
Jun 23 '16 at 1:17
source share

Also, make sure that the Console is actually visible in Xcode (that is, make sure that the right-side icon is highlighted in blue, as shown in the figure below). After I updated Xcode, it hid the console and showed me only the Variables view. This showed that NSLog() was not working correctly, while it really worked correctly, I just could not see the result.

enter image description here

+7
Apr 20 '17 at 2:39 on
source share

Hmmm ... similar to the "OS_ACTIVITY_MODE" property: "disable" PREVENTS NSlog from displaying in the Xcode 9 log.

Reducing this value in my scheme, I restored my logs.

+5
Oct 03 '17 at 19:19
source share

For everyone who comes to this in the future. The reason NSLog does not print to syslog in iOS 10 and iOS 11 is due to Apple switching to Unified Logging.

You can see how WWDC talks about it here: https://developer.apple.com/videos/play/wwdc2016/721/

Documentation here: https://developer.apple.com/documentation/os/logging

Starting at 10, you should use os_log instead of NSLog.

How to find the logs on the disk: https://www.blackbagtech.com/blog/2017/09/22/accessing-unified-logs-image/

To summarize, the logs are located in /var/db/diagnostics which can be found for the virtual machine in /Users/USERNAME/Library/Developer/CoreSimulator/Devices/SIMULATOR-GUID/data/var/db/

Copy all the elements inside diagnostics and uuidtext into one folder (do not include folder diagnostics or uuidtext only what is inside).

Rename this folder foldername.xarchive .

Open it in Console.app or use log OSX util: log show <path to archive> --info --predicate <options>

+2
Mar 03 '18 at 6:47
source share

I am using Xcode 8, so I also ran into the same problem. And I solved this problem by adding value = disable to the simulator, but on a real machine, I am not adding a value.

+1
Sep 23 '16 at 6:01
source share

NSLog messages no longer appear when upgrading to Xcode 9.1 + iOS 11.1. The originally accepted answer gave me a way around this using the Console app and turning on Simulator ( see Lucas answer ).

In the “Console” application, in the “ Action ” section, I tried to select “ Include Debug Messages and uncheck the“ Include Info Messages (so the console does not load system messages). NSLog messages appeared in the console window in Xcode, but not in the console application.

I realized that there should have been a more direct way to disable or enable (i.e. by default ) NSLogs thanks to Coeur's comment in response to this answer. In my opinion, this is the best answer, because setting OS_ACTIVITY_MODE to disable or default will make more sense for beginners.

0
Nov 05 '17 at 4:00
source share



All Articles