简体   繁体   中英

NSLog output no where to be found, Xcode8

I'm trying to use NSLog statements to figure out the execution flow of my app, so I have one in main.m right after autoreleasepool:

@autoreleasepool {
    NSLog(@"app started"); //added breakpoint here, but debugger stopped at next line
    BOOL runningTests = NSClassFromString(@"XCTestCase") != nil; //stopped here instead of nslog.
    ...

Now, that statement is no where to be found. I've tried searching the console, using 'command + /' to bring up a console for the simulator and searched through the system.log there but still nothing. To see if I was even going through main I added a breakpoint on the log statement and it was being hit, or at least the debugger stopped on the statement after the log (shown in code snippet). Is there something that I don't understand about the app life cycle, for example are the logs being cleared at some point when the application is launched? I also have other NSLog statements in other functions that I expect to be called but they aren't printed either. Why aren't my logs being printed to console?

Side notes:

My console is indeed active, and the output I'm looking at is 'All Output'.

Is there another way I can determine the execution flow of my application? It's a really large app with lots of storyboards and view controllers. By execution flow I mean which views are hit first, what functions are called from those views, how the app determines the next view when the app loads (depending on if the user is logged in) etc...

Thanks in advance!

Edit: the pre-processor macros I have在此处输入图片说明

the NSlog is executed but is hidden among lots of other console debug outputs to solve this issue:

In Xcode8: 

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

add OS_ACTIVITY_MODE and check it, but don't add any value.

So thanks to Andrew Veresov and rmaddy I was able to figure out the issue. The problem was that I had the Appstore scheme selected in product->scheme. I had to change it to the development scheme for all the logs to print. I'm not sure exactly how this works because some log statements still print even though others don't. If anyone can elaborate on schemes and how they work then I'd really appreciate it.

UPDATE: The issue was actually that the appstore scheme defined a macro that was getting rid of NSLogs:

#ifndef __OPTIMIZE__
#define NSLog(...) NSLog(__VA_ARGS__)
#else
#define NSLog(...) {;}
#endif

So when I changed the scheme this macro was no longer being used, if you have this issue do as drekka said: "... do a global search for '#define NSLog' and see what comes up." You can remove the macro and your logs will show up.

Thanks a bunch drekka for pointing this out!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM