Xcode6 generates the prefix. PCH File

Source: Internet
Author: User

In xcode6, the new project does not have a PCH file by default. Apple must cancel the PCH file. At the beginning, many people may not be comfortable with it. If we want to use the PCH file, you need to add them manually. The steps are as follows: (directly)



@ Reason for cancellation:

One person on stackoverflow explained this as follows:
I suspect because of modules, which remove the need for #import <Cocoa/Cocoa.h>.
As to where to put code that you wocould put in a prefix header, There is no code you shoshould put in a prefix header. put your imports into the files that need them. put your definitions into their own files. put your macros... nowhere. stop writing macros unless there is no other way (such as when you need _ file __). if you do need macros, put them in a header and include it.
The prefix header was necessary for things that are huge and used by nearly everything in the whole system (like Foundation. h ). if you have something that huge and ubiquitous, you shoshould rethink your architecture. prefix headers make code reuse hard, and introduce subtle build problems if any of the files listed can change. avoid them until you have a serious build time problem that you can demonstrate is dramatically improved with a prefix header.
In that case you can create one and pass it into clang, but it's incredibly rare that it's a good idea.

This is probably because of the Single Component module. <Cocoa/Cocoa.h>Import
You should not put any code in your prefix code and put them in the file you actually need. Put your definition in their files. Do not use the macro definition ).. Unless it is not a last resort, (The reason why macro definition is not used here is that macro definition is processed during pre-compilation. Therefore, when you modify the macro definition, a large amount of code will be re-compiled. In addition, there are many potential macro definitions. because during pre-compilation, he won't be noticed ). If you are forced to use macro definition, put them in the header file to be included, rather than in the prefix file.
Prefix header files are frequently used and need to be used by almost all files in the system (such as foundation. h ). If you have a large number of things, you should rethink your architecture. When you modify some code of your prefix header, the prefix header causes the entire project to be re-compiled, which makes it difficult to reuse your code and causes some trivial build problems. Therefore, do not use the prefix header to avoid the time required to recompile the entire project.
If you still want to use pre-compilation, you can create a new one and pass it to the compiler's front-end. This method is rare (I have never used it), but it is indeed a good method.

@ You can also refer to: xcodeprecompileprefixheader Analysis

@! Reprinted, please note: [email protected] confused little bookboy

Xcode6 generates the prefix. PCH File

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.