.pch File in Xcode 6.1

2019-06-07 04:33发布

问题:

I have looked all over and cannot find a solution to this problem.

The problem involves adding a header file to an xcode 6.1 project. What I want to be able to do is add a header file that is automatically imported to each of the files I create.

i.e.

I create a.h & a.m.

Where previouslyMade.pch or previouslyMade.h definitions are already included.

I've looked through build settings and there isn't an option to update the .pch file.

Is there a solution to this or have I got to import a .h file every time I make a new file?

Thanks

回答1:

  1. You'll need to create a PCH file named ProjectName-Prefix.pch. In the new file dialog you'll find PCH under Other.
  2. Go to Project > Build Settings and search "Prefix Header". Under "Apple LLVM 6.0 - Language" add your PCH file: ProjectName/ProjectName-Prefix.pch note: make sure you select 'All' not 'Basic'
  3. Now add any headers you want globally included in your PCH file
  4. Clean and rebuild your project.