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.

Nick
  • 4,820
  • 18
  • 31
  • 47
  • 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 – Scofield Tran Feb 03 '15 at 02:46
  • Hi @pf2707. I hope this answer will enable you to find the correct place - http://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. – Nick Feb 07 '15 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 – Scofield Tran Feb 09 '15 at 04:10
  • possible duplicate of [Why isn't ProjectName-Prefix.pch created automatically in Xcode 6?](http://stackoverflow.com/questions/24158648/why-isnt-projectname-prefix-pch-created-automatically-in-xcode-6) – DanSkeel Apr 23 '15 at 07: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. – Nick Apr 24 '15 at 04:15

1 Answers1

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

nacho4d
  • 43,720
  • 45
  • 157
  • 240
abavisg
  • 371
  • 2
  • 9
  • 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. – Nick Nov 22 '14 at 09:12
  • 3
    No problem Nick. I hope you are ok now and it was a minor accident. Take care! :) – abavisg Nov 23 '14 at 09:46
  • 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). – Marc Johnson Apr 25 '21 at 01:36