Hide strange unwanted Xcode logs

前端 未结 13 2723
孤独总比滥情好
孤独总比滥情好 2020-11-22 02:34

When using the Xcode 8+ and creating a new blank project, the following logs appear when running the application:

2016-06-13 16:33:34.406093 TestiOS10[8209:1         


        
相关标签:
13条回答
  • 2020-11-22 03:04

    This is still not fixed in Xcode Version 8.0 beta 2 (8S162m) for me and extra logs are also appearing in the Xcode console

    ** EDIT 8/1/16: This has been acknowledged in the release notes for Xcode 8 Beta 4 (8S188o) as an issues still persisting.

    Known Issues in Xcode 8 beta 4 – IDE

    Debugging

    • Xcode Debug Console shows extra logging from system frameworks when debugging applications in the Simulator. (27331147, 26652255)

    Presumably this will be resolved by the GM release. Until then patience and although not ideal but a workaround I'm using is below...

    Similar to the previous answer I am having to:

    • prefix my print logs with some kind of special character (eg * or ^ or ! etc etc)

    • Then use the search box on the bottom right of the console pane to filter my console logs by inputing my chosen special character to get the console to display my print logs as intended

    0 讨论(0)
  • 2020-11-22 03:04

    This solution has been working for me:

    1. Run the app in the simulator
    2. Open the system log ( + /)

    This will dump out all of the debug data and also your NSLogs.

    To filter just your NSLog statements:

    1. Prefix each with a symbol, for example: NSLog(@"^ Test Log")
    2. Filter the results using the search box on the top right, "^" in the case above

    This is what you should get:

    0 讨论(0)
  • 2020-11-22 03:06

    In Xcode 10 the OS_ACTIVITY_MODE variable with disable (or default) value also turns off the NSLog no matter what.

    So if you want to get rid of the console noise but not of your own logs, you could try the good old printf("") instead of the NSLog since it is not affected by the OS_ACTIVITY_MODE = disable.

    But better check out the new os_log API here.

    0 讨论(0)
  • 2020-11-22 03:08

    Alright. There seems to be a lot of commotion about this one, so I'll give y'all a way to persist it without using that scheme trick. I'll address the iOS Simulator specifically, but this also might need to be applied for the TV Sim as well which is located in a different dir.

    The problem that is causing all of this stuff are plists located within the Xcode directory. There is a process that gets launched called configd_sim when the Sim starts that reads the plists in and prints debugging information if the plists specify they should be logged.

    The plists are located here:

    /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/Preferences/Logging/Subsystems

    If you are playing around with a beta, take note that the dir will be different.

    You will see numerous plists in this directory. Now, build and run your application and observe the logs. You are looking for the content immediately followed by the subsystem: part. It is the name immediately following this that represents the corresponding problematic plist.

    From there, either modify the plist to knock out the debugging [Level] key/value which is a dictionary containing the "Enable" => "Default" key/value... or just simply delete the plist. Note, that you will need to be root to do either of these since they're located in the Xcode application.

    the plutil -p command might be of use to you as well. i.e.

    plutil -p /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator.sdk/System/Library/Preferences/Logging/Subsystems/com.apple.BackBoardServices.fence.plist
    

    This gave me one of the problematic plists which contained:

    { "DEFAULT-OPTIONS" => { "Level" => { "Enable" => "Default" }}}

    Good luck :]

    0 讨论(0)
  • 2020-11-22 03:08

    This is no longer an issue in xcode 8.1 (tested Version 8.1 beta (8T46g)). You can remove the OS_ACTIVITY_MODE environment variable from your scheme.

    https://developer.apple.com/go/?id=xcode-8.1-beta-rn

    Debugging

    • Xcode Debug Console no longer shows extra logging from system frameworks when debugging applications in the Simulator. (26652255, 27331147)

    0 讨论(0)
  • 2020-11-22 03:16

    Building on the original tweet from @rustyshelf, and illustrated answer from iDevzilla, here's a solution that silences the noise from the simulator without disabling NSLog output from the device.

    1. Under Product > Scheme > Edit Scheme... > Run (Debug), set the OS_ACTIVITY_MODE environment variable to ${DEBUG_ACTIVITY_MODE} so it looks like this:

    1. Go to your project build settings, and click + to add a User-Defined Setting named DEBUG_ACTIVITY_MODE. Expand this setting and Click the + next to Debug to add a platform-specific value. Select the dropdown and change it to "Any iOS Simulator". Then set its value to "disable" so it looks like this:

    0 讨论(0)
提交回复
热议问题