PCH File in Xcode 6
Asked Answered
T

6

182

In my previous projects, I can find the .pch file under Supporting Files.

But now in Xcode 6, I couldn't find any .pch file. Any steps should I do to produce this file?

Tape answered 19/6, 2014 at 11:13 Comment(1)
Shame that you've not got an answer to this yet, I've just run across the same issue. Did you ever find an answer?Vega
V
80

Add the pch file which is under Others in File-New...and don't forget to add it to your LLVM6.0 - Language section of Build Settings as Project/whateveryounamedyourpchfile.pch

Villada answered 27/7, 2014 at 5:5 Comment(0)
R
433
  1. Make new file: ⌘cmd+N
  2. iOS/Mac > Other > PCH File > YourProject-Prefix.pch.
  3. Make sure you display "All" and not "Basic". (Blue buttons)
  4. Project > Build Settings > Search: "Prefix Header".
  5. Under "Apple LLVM 7.0" you will get the Prefix Header key.
  6. Type file directory. e.g: "$(SRCROOT)/$(PROJECT_NAME)/ProjectName-Prefix.pch".
  7. Clean project: ⌘cmd+⇧shift+K
  8. Build project: ⌘cmd+B

Prefix Header Image

Reclusion answered 30/9, 2014 at 16:49 Comment(8)
I cannot find prefix header in build settings.. How can i add .pch in my project?Permanence
Updated the answer with an image. :)Reclusion
Thank you! Why to change something that works perfectly?Suboceanic
@Reclusion what is the difference between YourProjectName and YourProject, and also when you create the .pch file should I check any checkbox for targets?Aetiology
Well it depends on your project folder name and the name you gave it for the pch file. YourFolder/YourPch.pch. And I think the target should be your project/app? @LaurStefanReclusion
XCode 7 does not provide the "Prefix Header" option.Pyralid
Yes it does, under "Apple LLVM 7.0 Language" in Build Settings. Just make sure you are viewing All and not Basic, top left corner (blue buttons). (:Reclusion
doesn't appear to be a preprocessing key for xcode 8.0Leavy
V
80

Add the pch file which is under Others in File-New...and don't forget to add it to your LLVM6.0 - Language section of Build Settings as Project/whateveryounamedyourpchfile.pch

Villada answered 27/7, 2014 at 5:5 Comment(0)
R
9

Rob Napier's answer at Why isn't ProjectName-Prefix.pch created automatically in Xcode 6? is worth reading. He points out that a PCH file is probably not a good idea, and suggests explicitly including .h files into modules that need them.

Rorrys answered 3/10, 2014 at 20:33 Comment(1)
while Rob's answer is indeed worth reading, you might also include in your answer that the comments below the answer debate most of what he said. Rob's reputation plays big part of the deal. But one could agree that the answer is subjective, and represents Rob's personal choice not to have a .pch file in his projects.Juni
T
6

I've found out that with Xcode 6. You need to manually create the PCH File.

File -> New -> File -> iOS -> C and C++ -> PCH File.

Tape answered 30/6, 2014 at 2:27 Comment(1)
in the build setting under prefix.header you just need to type your .pch file nameWoodnote
W
2

There is a minor error in the answer provided above.Please note that in the build setting under prefix.header you just need to type your .pch file name –

Woodnote answered 30/7, 2015 at 10:6 Comment(0)
N
1

In my case issue was getting ,no input file error

I fixed by Removing .pch file from project and adding again this work for me.hope this help someone.

Necklace answered 1/2, 2016 at 13:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.