Application Scenarios for PCH files:
1. Used to define some global macros
2. Used to import some global access to the header file (if only need to let. m or. mm file access, do not need to let. c file access, then you need to write the head file to #ifdef _objc_ #endif之间, because. m and. mm files have a default _objc_ Macros and. c files are not ).
3. Use the log from definition
The contents of the PCH file can be accessed by all files, including. C,. m,. mm files. The default. m,. mm files have a # define _OBJC_ macro, and. c files do not have the macro, so you can take the. m,. mm access to the. h header file that you need to access without the. c file into this macro of the PCH file, and put the. c file into this macro of the PCH file that needs to be accessed.
1. ——————————————————
#define _global_
2. ——————————————————
#ifdef _OBJC_
#import "Ws.h"
#endif
3. ——————————————————
For debugging convenience, the debug phase often uses NSLog () to print out the output information to see if the information program is running correctly
However, the release phase often does not need to output these debugging information, manual comment or delete nslog () will be more troublesome, so you can use the following methods to operate:
In the PCH file,
#ifdef _OBJC_
#endif
Added between
#define WSLOG (...) NSLog (__va_args__)
// Commissioning Phase: #ifdef _objc_ #define Wslog (...) NSLog (__va_args__)#endif// release phase:#ifdef _objc_#define // NSLog (__va_args__) #endif
Or a smarter notation:
#ifdef _objc_ #ifdef Debug / debug Phase #define wslog (...) NSLog (__va_args__)#else // release phase #define wslog (...) #endif #endif
The relative path of the PCH needs to be set in the project:
Click Project->building setting-> Search prefix header-> Enter the relative path of the PCH file in the project, such as:
Note: The absolute path is not set:/users/user name/desktop/wechat/wechat/prefixheader.pch
The path to the correct PCH file that needs to be set: wechat/prefixheader.pch
Use of PCH files