Go How to add a PCH file in Xcode6

Source: Internet
Author: User

Before Xcode6, when a new project is created, the system will automatically create a PCH (precompile header) file with the name of the project, and during the development process, the header files that are widely used throughout the project can be included in the file. The compiler will automatically add the header files in the PCH file to all the source files, so that you can use the contents of the header file without using import when you need to use the relevant classes, to a large extent, the convenience of programming, but the potential also brings some problems, This is why the PCH is no longer created by default in Xcode6.

On the StackOverflow and loss of the PCH, there is a bit of talk on the http://stackoverflow.com/questions/24158648/: Why-isnt-projectname-prefix-pch-created-automatically-in-xcode-6

As to where to put code this you would put in a prefix header, there are no code you should 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. The Stop writing macros unless there is the no other (such as when you need __file__). If You do need macros, put them in a header and include it.

The prefix header is necessary for things that is huge and used by nearly everything in the whole system (like Found Ation.h). If you have something the huge and ubiquitous, you should 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 had a serious build time problem that can demonstrate was dramatically improved with a prefix hea Der.

In this case you can create one and pass it to clang, but it's incredibly rare that it's a good idea.

However, there are times when you need a PCH file, so how do I add a PCH file to Xcode6?

First, Command+n, open the new File window: ios->other->pch file, create a PCH, add the header file name you need to introduce:

Second, modify the project configuration file, add the path of the PCH file you just created to the precompile header option in building setting, and note that the debug and release two columns are added:

Now that you're done, compile it again, and the newly added PCH file will work properly with ^_^.

Reprinted from: http://blog.csdn.net/lihuiqwertyuiop/article/details/39268101

Go How to add a PCH file in Xcode6

Related Article

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.