3

When creating a new project in Xcode 6, the generated project is missing the Prefix.pch file. Is this intended? Should we continue making our own, or is there a new method we should be using instead?

I don't use it too much, but having a few key system frameworks like Foundation and UIKit available in every file is useful, along with a couple oft-used 3rd party frameworks. Is the preferred solution to just create our own prefix file manually and configure it in the build settings, or something else?

Cory Imdieke
  • 14,140
  • 8
  • 36
  • 46
  • There is a question about it. You can check it here: http://stackoverflow.com/questions/24158648/why-isnt-projectname-prefix-pch-created-automatically-in-xcode-6 – Thinh Phan Oct 01 '14 at 04:09

1 Answers1

7

You can easily add the Prefix.pch file manually like this:

1) Add new .pch file to your project -> New file -> Other -> PCH file

2) Goto your project's build setting.

3) Search "prefix header". You should find that under Apple LLVM.

4) Paste this in the field $(SRCROOT)/yourPrefixHeaderFileName.pch

5) Clean and build the project

If you use Objective-C just like before xCode 6 you will also have to import UIKit and Foundation frameworks in the .pch file. Otherwise you will have to import these frameworks manually in each header file. You can add the following code anyway as it tests for the language used:

#ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
#endif
mgm
  • 1,298
  • 14
  • 16