This paper reproduces the function and usage of http://blog.csdn.net/lvxiangan/article/details/21325093 prefix.pch.
Hello world_prefix.pch: The extension. pch means "precompiled header", which is a list of header files from the external framework that you will use for your project. Prefix header options in the engineering--targets--build SETTINGS--APPLELLVM 5.0 Language
Xcode will compile these headers into the file, which will reduce the time you compile the project when you choose Build or build and go. The usual header file has been automatically included in the PCH, and the system will include this file before compiling each CPP file. This saves the time to add the include, which is equivalent to accelerating the compilation. There is also can be put into the macro, in the whole project can be used. Save time.
When we create a new project, in the supporting files file will see a file ending with-prefix.pch, PCH full name is "precompiled Header", that is, precompiled header file, The files stored in the project some infrequently modified code, such as the usual framework header files, so that the purpose of improving the compiler speed. When we modify a file code in a project, the compiler does not recompile all the files, but compiles the files. if a file in the PCH is modified, then the other files contained in the PCH file will be recompiled once, which will consume a lot of time, so it is best to add files that are rarely changed or not changed, or are precompiled code snippets;
When you create a new project, the code in the PCH suffix file is
#ifdef __objc__
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#endif
You might think this precompiled code is rare, but you can look at the UIKit.h definition file
//
UIKit.h
UIKit
//
Copyright (c) 2005-2013, Apple Inc. All rights reserved.
//
#import <UIKit/UIKitDefines.h>
#import <UIKit/UIAccelerometer.h>
#import <UIKit/UIAccessibility.h>
#import <UIKit/UIActivityIndicatorView.h>
#import <UIKit/UIActivity.h>
#import <UIKit/UIActivityItemProvider.h>
#import <UIKit/UIActivityViewController.h>
#import <UIKit/UIAlert.h>
#import <UIKit/UIApplication.h>
#import <UIKit/UIBarButtonItem.h>
#import <UIKit/UIBarItem.h>
#import <UIKit/UIBezierPath.h>
#import <UIKit/UIButton.h>
#import <UIKit/UICollectionView.h>
#import <UIKit/UICollectionViewCell.h>
#import <UIKit/UICollectionViewController.h>
#import <UIKit/UICollectionViewFlowLayout.h>
#import <UIKit/UICollectionViewLayout.h>
#import <UIKit/UICollectionViewTransitionLayout.h>
#import <UIKit/UIColor.h>
#import <UIKit/UIControl.h>
#import <UIKit/UIDataDetectors.h>
#import <UIKit/UIDatePicker.h>
#import <UIKit/UIDevice.h>
#import <UIKit/UIDocument.h>
#import <UIKit/UIDocumentInteractionController.h>
#import <UIKit/UIEvent.h>
#import <UIKit/UIFont.h>
#import <UIKit/UIFontDescriptor.h>
#import <UIKit/UIGeometry.h>
#import <UIKit/UIGestureRecognizer.h>
#import <UIKit/UIGraphics.h>
#import <UIKit/UIImage.h>
#import <UIKit/UIImagePickerController.h>
#import <UIKit/UIImageView.h>
#import <UIKit/UIInputView.h>
#import <UIKit/UIInterface.h>
#import <UIKit/UILabel.h>
#import <UIKit/UILocalNotification.h>
#import <UIKit/UILocalizedIndexedCollation.h>
#import <UIKit/UILongPressGestureRecognizer.h>
#import <UIKit/UIManagedDocument.h>
#import <UIKit/UIMenuController.h>
#import <UIKit/UIMotionEffect.h>
#import <UIKit/UINavigationBar.h>
#import <UIKit/UINavigationController.h>
#import <UIKit/UINib.h>
#import <UIKit/UINibDeclarations.h>
#import <UIKit/UINibLoading.h>
#import <UIKit/UIPageControl.h>
#import <UIKit/UIPageViewController.h>
#import <UIKit/UIPanGestureRecognizer.h>
#import <UIKit/UIPasteboard.h>
#import <UIKit/UIPickerView.h>
#import <UIKit/UIPinchGestureRecognizer.h>
#import <UIKit/UIPopoverController.h>
#import <UIKit/UIPopoverBackgroundView.h>
#import <UIKit/UIPrintError.h>
#import <UIKit/UIPrintFormatter.h>
#import <UIKit/UIPrintInfo.h>
#import <UIKit/UIPrintInteractionController.h>
#import <UIKit/UIPrintPageRenderer.h>
#import <UIKit/UIPrintPaper.h>
#import <UIKit/UIProgressView.h>
#import <UIKit/UIReferenceLibraryViewController.h>
#import <UIKit/UIRefreshControl.h>
#import <UIKit/UIResponder.h>
#import <UIKit/UIRotationGestureRecognizer.h>
#import <UIKit/UIScreen.h>
#import <UIKit/UIScreenEdgePanGestureRecognizer.h>
#import <UIKit/UIScreenMode.h>
#import <UIKit/UIScrollView.h>
#import <UIKit/UISearchBar.h>
#import <UIKit/UISearchDisplayController.h>
#import <UIKit/UISegmentedControl.h>
#import <UIKit/UISlider.h>
#import <UIKit/UISplitViewController.h>
#import <UIKit/UIStepper.h>
#import <UIKit/UIStoryboard.h>
#import <UIKit/UIStoryboardPopoverSegue.h>
#import <UIKit/UIStoryboardSegue.h>
#import <UIKit/UIStringDrawing.h>
#import <UIKit/UISwipeGestureRecognizer.h>
#import <UIKit/UISwitch.h>
#import <UIKit/UITabBar.h>
#import <UIKit/UITabBarController.h>
#import <UIKit/UITabBarItem.h>
#import <UIKit/UITableView.h>
#import <UIKit/UITableViewHeaderFooterView.h>
#import <UIKit/UITableViewCell.h>
#import <UIKit/UITableViewController.h>
#import <UIKit/UITapGestureRecognizer.h>
#import <UIKit/UITextChecker.h>
#import <UIKit/UITextField.h>
#import <UIKit/UITextInput.h>
#import <UIKit/UITextInputTraits.h>
#import <UIKit/UITextView.h>
#import <UIKit/UIToolbar.h>
#import <UIKit/UITouch.h>
#import <UIKit/UIVideoEditorController.h>
#import <UIKit/UIView.h>
#import <UIKit/UIViewController.h>
#import <UIKit/UIWebView.h>
#import <UIKit/UIWindow.h>
#import <UIKit/NSAttributedString.h>
#import <UIKit/NSLayoutConstraint.h>
#import <UIKit/NSLayoutManager.h>
#import <UIKit/NSParagraphStyle.h>
#import <UIKit/NSShadow.h>
#import <UIKit/NSStringDrawing.h>
#import <UIKit/NSText.h>
#import <UIKit/NSTextAttachment.h>
#import <UIKit/NSTextContainer.h>
#import <UIKit/NSTextStorage.h>
#import <UIKit/UIStateRestoration.h>
#import <UIKit/UIViewControllerTransitioning.h>
#import <UIKit/UIViewControllerTransitionCoordinator.h>
#import <UIKit/UIDynamicAnimator.h>
#import <UIKit/UIDynamicBehavior.h>
#import <UIKit/UIPushBehavior.h>
#import <UIKit/UISnapBehavior.h>
#import <UIKit/UIDynamicItemBehavior.h>
#import <UIKit/UIGravityBehavior.h>
#import <UIKit/UIAttachmentBehavior.h>
#import <UIKit/UICollisionBehavior.h>
This is a lot of it, the project every time the compilation is not very time-consuming, these are Apple's internal definition of standard header files, we can not and do not have permission to modify these header file definition content, so, when placed in the PCH file will speed up the compilation process;
We see that some of these files have also been added to the inside, and might wonder if these headers have changed much?
Pre-compilation added
#import "ASIHTTPRequest.h"
#import "ASIFormDataRequest.h"
#import "ASIHTTPRequestDelegate.h"
#import "ASIHTTPRequestConfig.h"
#import "TBXML.h" #import "Tbxml+http.h"
#import "Tbxml+compression.h" #import "Config.h"
#import "EGORefreshTableHeaderView.h"
#import "DataSingleton.h"
#import "ImgRecord.h" #import "IconDownloader.h"
#import "MBProgressHUD.h"
#import "GCDiscreetNotificationView.h"
#import "NdUncaughtExceptionHandler.h"
#import "JSNotifier.h" #import "AFOSCClient.h"
#import "AFHTTPRequestOperation.h"
#import "AFXMLRequestOperation.h"
In fact, these files are special in that they are the third-party class library header files, the third-party class library to highly encapsulate some objects, leaving the interface, and then we can directly call on the class library interface, these third-party libraries are generally more simple than the original native iOS, such as the Tbxml parsing library, It's better than the Nsxmlpaser parser speed function that comes with iOS.
There are also some macro definitions are more commonly used in macro definitions, such as defined API interface, these interfaces are of course very few;
And then the last thing left.
#ifdef DEBUG
#define DEBUGLOG (...) NSLog (__va_args__)
#define DEBUGMETHOD () NSLog (@ "%s", __func__)
#else #define DEBUGLOG (...)
#define DEBUGMETHOD ()
#endif
The project has debug version and release Version,debug versions is the program development process, it contains all the debugging information, some commonly used nslog print logs, in the program debugging process according to the debugging information we set can see what place error, We run a small program when running, will not be the first to think of debugging a breakpoint, it should be the first thought of NSLog, see which function method did not execute, to see if the value of which array is not taken out. Release version is a release, and not printing nslog can speed up the program and reduce memory usage. But to a big project, there will be a lot of such nslog, when we work perfectly run, release release version of the time, we go to a line of comments NSLog? If the project is now based on the original version 1.2 release, we modify the program when the original comment is not also canceled, it is very troublesome and troublesome.
Therefore, the use of the macro command here, the meaning of the above code is to use the macro command to make a judgment, if the debug is true, then compile #ifdef to #endif macro definition, otherwise the compiler will not compile;
Where is this debug setting? There is a "debug=1" in "Target > Build Settings > Preprocessor Macros > Debug".
When run Test Profile Analyze archive, you can set debug and release two modes as needed, so we can use a macro to set whether or not to print debug information
iOS prefix.pch