bertday
bertday

Reputation: 10971

NSLog not printing to console

I have an Xcode project I've been working on for months. I've never had a problem with NSLog, but after upgrading to Xcode 4.2 nothing will log to the console. I even tried throwing this in viewDidLoad:

    - (void)viewDidLoad
{
    [super viewDidLoad];

    NSLog(@"Can anyone hear me?");

And nothing. Is anyone else having this problem or know a solution?

Upvotes: 57

Views: 47480

Answers (8)

chinthan
chinthan

Reputation: 1

This similar issue was observed after upgrade to Xcode 15.0.1 for macOS. NSLog was not printing to console. The solution to this issue that worked for me is as mentioned below. Refer to https://lapcatsoftware.com/articles/2023/10/5.html , https://developer.apple.com/forums/thread/742594 for more info.

  1. Under Product->Scheme->Edit Scheme->Run->Arguments, add an environment variable with key "IDELogRedirectionPolicy" & value "oslogToStdio"
  2. Under Product->Scheme->Edit Scheme->Run->Options, set the console to "Xcode" or "Terminal"

Upvotes: 0

bertday
bertday

Reputation: 10971

Well, this is embarrassing. The console got deactivated somehow and I was actually watching the variables window. Pressing Shift + + C did the trick.

Many thanks to Robert King on this thread:

https://devforums.apple.com/message/565880#565880

Upvotes: 79

Dave Levy
Dave Levy

Reputation: 1192

I just experienced this, so here's another thing to check.

-> Make sure you don't have anything typed in the Filter field below the Log Output. So, in my case I was searching for a term in the logger and forgot to delete the searched terms out of the Filter text field. DOH!

Upvotes: 1

Igor
Igor

Reputation: 12303

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

When on simulator, add the Name OS_ACTIVITY_MODE and the Value Variables disable and check it (Product -> Scheme -> Edit Scheme -> Run -> Arguments -> Environment). enter image description here

When on device, only add OS_ACTIVITY_MODE and check it(don't add the Value). You'll see the NSLog in the Xcode8 Console. enter image description here

Upvotes: 78

Vincent
Vincent

Reputation: 4409

In iOS10, a lot of system logging is displayed on the console. This can be disabled by including the OS_ACTIVITY_MODE = disabled in the Run Arguments for your scheme

However for iOS10, NSLog messages will not be displayed anymore. In lower iOS versions the messages will still be displayed. So maybe for most test cases you can use a lower iOS version.

Otherwise you can include a Swift function which prints (print function) your text, this is working okay in iOS10.

Tested on iOS10.0.2 and iOS9.3

Upvotes: 13

bharathi kumar
bharathi kumar

Reputation: 208

I had the same issue. The trick is to search and remove the below mentioned line from the project.

  #define NSLog(...)

Search the entire project and remove it.

Upvotes: 3

Jack James
Jack James

Reputation: 5372

My issue was that I'd accidentally severed the referencing outlet from App Delegate (delegate - file's owner).

Upvotes: 0

timv
timv

Reputation: 3366

My issue is that I have Debugger Output selected. Once I changed it to either All output or target output NSLogs appear fine.

In case this confuses you its on the left of the Debug area.

Upvotes: 10

Related Questions