iOS 10.0 XCode 8.3 Release/Debug 发布/调试模式下的日志打印的关闭和开启Demo全解

1: Create PCH File

1.1 File -> New -> File...

image_1.png

1.2 iOS -> Other -> PCH File -> Next

image_2.png

1.3 Add a name or default -> select you project!!! -> create

image_3.png
image_4.png
//
// CancelNSLogTest-PrefixHeader.pch
// CancelNSLogTest
//
// Created by Anter on 5/17/17.
// Copyright © 2017 Anter. All rights reserved.
//

#ifndef CancelNSLogTest_PrefixHeader_pch
#define CancelNSLogTest_PrefixHeader_pch

// Include any system framework and library headers here that should be included in all compilation units.
// You will also need to set the Prefix Header build setting of one or more of your targets to reference this file.

#ifdef DEBUG
#define ANLog(...) NSLog(__VA_ARGS__)
#else
#define ANLog(...)
#endif

#endif /* CancelNSLogTest_PrefixHeader_pch */

1.4 Check the setting...

image_5.png

2:Deal with the rubbish log in XCode 8.0+:

image_6.png
// deal with the problem that rubbish log is logging
// OS_ACTIVITY_MODE = disable
image_7.png

3: Coding ...

in the codes, use 
ANLog(@"xxxx = %@", variable) 
replace NSLog(@"%@", variable); 
Clean project and run ...
image_8.png

4:test the log ...

image_9.png
image_10.png

Change the Debug or Release mode and run...

你可能感兴趣的:(iOS 10.0 XCode 8.3 Release/Debug 发布/调试模式下的日志打印的关闭和开启Demo全解)