10

In Xcode 6.1, creating a new project does not create a precompiled header file using the single view iOS project template. If I add one manually, any definitions in the pch file are not available in any other source files.

I've looked at many threads and questions and tried cleaning, re-buiding, re-starting, deleting derived data and manually removing the CACHE_ROOT/SharedPrecompileHeaders folder. All to no avail, though.

Some info suggests ticking to include in targets, but this is disabled for pch and other header files now.

See comment below.

5
  • Hi @Nick, I faced some other issues related to yours. Can you help me how can I manually remove CACHE_ROOT/SharedPrecompileHeaders folder. It has the path var/folders/49/..... and I can't find it Commented Feb 3, 2015 at 2:46
  • Hi @pf2707. I hope this answer will enable you to find the correct place - stackoverflow.com/a/12823466/2070111 - it should tell you the exact CACHE_ROOT for your project and then you can move to it and remove the headers. Commented Feb 7, 2015 at 17:03
  • Thank @Nick, I find out the solution. There's command line to do it, just type cd /private/var/folders, and can delete file in this folder Commented Feb 9, 2015 at 4:10
  • possible duplicate of Why isn't ProjectName-Prefix.pch created automatically in Xcode 6? Commented Apr 23, 2015 at 7:27
  • DanSkeel obviously has too much time! The 'other' question accepted an answer that didn't actually answer the question, but was a rant - the real answer is buried about fourth down, so I had given up before I got to the answer, it turns out, even though I had read it before posting. For someone actually looking for the answer quickly (which is what I use SO for rather than to waste my time trolling), my question is more useful. Commented Apr 24, 2015 at 4:15

1 Answer 1

18

Have you tried adding the path of the pch file?

Go to your project -> Build Settings -> Apple LLVM 6.0 Language.

Under it, set the following things:

  • Precompile Prefix Header: Set it to YES
  • Prefix Header: Set the path to the pch file

Update 2018/09/23: In Xcode10 it is under Apple Clang - Language

enter image description here

Sign up to request clarification or add additional context in comments.

3 Comments

Sorry for the delay in replying, I fell down some stairs and have been a bit pre-occupied! I hadn't noticed this. You are absolutely correct. Thank you very much.
No problem Nick. I hope you are ok now and it was a minor accident. Take care! :)
note that you cannot add this setting for the first time from within a project opened with podfile (suffix xcworkspace). I believe initially it must be added to the actual xcode project (suffix xcodeproj).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.