iOS 10 doesn't print NSLogs
Solution 1
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)
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.
Solution 2
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)
Solution 3
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.
Solution 4
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.
Solution 5
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)
Tyler Sheaffer
Updated on September 28, 2020Comments
-
Tyler Sheaffer over 3 years
Nothing prints from
NSLog
on Xcode 8.0 beta (8S128d).printf
is unchangedHere'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
-
kientux almost 8 yearsI can't see NSLog output in real iOS 10 device neither. If you're using real devices, you can open Devices window (Shift + Command + 2) and see device logs there, but it's hard to look at debugging app log because the console shows all logs from system and apps.
-
TahoeWolverine over 7 yearsI'm not seeing the NSLogs for my app in the devices window under iOS 10 GM...are you having the same problem?
-
kientux over 7 yearsI can see logs in Xcode 7 with iOS 10 GM, no needs to open devices window anymore.
-
TahoeWolverine over 7 yearsI'm not talking about running from Xcode, though, I'm talking about the logs being printed from a deployed app.
-
m8labs over 7 years>"Don't add the Value" I set it to "disable" and it works! Empty field doesn't work for me.
-
user6833743 over 7 yearsAre you sure it works when real iphone device debugging, not the simulator ? If I set it to "disable", the console can't NSLog when real iphone debugging.
-
m8labs over 7 yearsI've checked now without "disable", it works on device now, but broken on simulator, it shows everything now again...
-
user6833743 over 7 yearsYep, that's it ! The way to solve the bug of Xcode8 + iOS10: When on sumulator, add the Name "OS_ACTIVITY_MODE" and the Value "disable" and check it. When on device, only add "OS_ACTIVITY_MODE" and check it(Don't add the Value). You will see the NSLog in the Xcode8 Console.
-
jhurray over 7 yearsAny progress on this?
-
ChandreshKanetiya over 7 yearsI have only add "OS_ACTIVITY_MODE" and check it(Don't add the Value). It will not print whole NSLog statement in the Xcode8 Console. If I print NSArray of 100 records then it will display some records and then break.
-
Toland Hon over 7 yearsIs there a way to use specify different environment variables based on architecture so that I can enable OS_ACTIVITY_MODE only on simulator?
-
Elist over 7 yearsNSLogs and printf's are omitted from iOS 10 device log in deployed applications. You can add a global macro to replace it with a call directly to
os_log
. -
greenhouse over 7 yearsis there anyway to automate this process? its really really annoying that we have to remember to go back and forth like this : /
-
mobjug over 7 yearsThis does not work for me. NSLogs do not show up for deployed applications. I use xcode 8.1(running on Mac 10.11) with iOS 10 device.
-
xiaoyaoworm over 7 yearsI have a SDK project, I put my own log there, it is not working on my iOS10 device, but still working on my iOS9 device. I follow the same way to change SDK and my SDK test app with this "disable", still now working on my side. Any idea? thanks.
-
Max MacLeod almost 7 yearsjust a comment that if one is too lazy to enable OS_ACTIVITY_MODE then dump will output variables regardless of OS_ACTIVITY_MODE value.
-
DJ2 over 6 yearsAlso can activate console with
Shift + ⌘ + C
Xcode version 8.3.3 -
fruitcoder over 6 yearsThanks, made my day!
-
Alessio Campanelli over 6 yearsi'm having some issues with Xcode 9. i inserted the argument: OS_ACTIVITY_MODE but it seems don't works...
-
LazyLastBencher over 6 yearsSetting
OS_ACTIVITY_MODE
toDEBUG_MODE
makes sure logs are seen only in debug mode. -
Cœur over 6 yearsThis solution will hide all NSLog starting with Xcode 9. To keep NSLog, replace
disable
withdefault
. -
Cœur over 6 yearsThis solution will hide all NSLog starting with Xcode 9. To keep NSLog, replace
disable
withdefault
. -
Cœur over 6 yearsThis solution will hide all NSLog starting with Xcode 9. To keep NSLog, replace
disable
withdefault
. -
Joel over 6 yearsThis answer should be updated to account for @Cœur's correction for Xcode 9.
-
Greg about 6 yearsIn my opinion this is the correct answer.
OS_ACTIVITY_MODE
withdisable
ordefault
is direct -
kakyo over 4 yearsWhat about on iOS?
-
Ornithopter over 3 yearswhat a great ui design @Apple, fullof unknown-meaning icons