recreating precompiled headers

Member
Posts: 86
Joined: 2008.04
Post: #1
After deleting a precompiled header file (.pch), my app no longer builds.

I am using the latest XCode.

Is there a way to instruct XCode to rebuild the precompiled header(i have already done a clean all)?

Shouldnt this be automatic?

Thanks for any advice
Quote this message in a reply
Member
Posts: 86
Joined: 2008.04
Post: #2
Just to clarify - Xcode is failing to rebuild the prefix precompiled header file.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #3
No, the .pch file is just a regular header file that's part of your source. The precompiled version of that header has extension "gch" and is either in your build folder or a user-wide cache of precompiled headers.
Quote this message in a reply
Member
Posts: 86
Joined: 2008.04
Post: #4
Thanks for the reply - I did get it working by simply recreating the .pch with a touch command.

I could replicate the problem by starting a new project, building it, and then deleting the .pch. After that point, a Build or even a Clean All..Build it would always fail with the error:
arm-apple-darwin9-gcc-4.0.1: /Users/username/prj_iphone/MyTouch/MyTouch_Prefix.pch: No such file or directory

Shouldn't xcode auto-recreate the prefix.pch for me?

BTW- OSC - What is your opinion of the latest XCode? It seems greatly improved, no?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
Like I said, no, Xcode won't regenerate the .pch, it is a regular source file. You wouldn't expect Xcode to regenerate MyDocument.m if you delete it; you shouldn't expect Xcode to regenerate MyProject_Prefix.pch. The .gch file is the compiled version of it; Xcode will rebuild that if you delete it (just as it will rebuild MyDocument.o if you delete that).

Despite the minor improvements like error bubbles and major improvements like search in the documentation window, they haven't addressed the fundamental problems with Xcode (like, say, the UI being horrendously awful, or copying resources working).
Quote this message in a reply
Member
Posts: 86
Joined: 2008.04
Post: #6
Ahh - Now I get what you are saying - the .pch was a just "convenience" file created by when it generated the sample. It is just another source file, and I could add my own headers for it to include if I want - but there is no way it would automatically create it for me.

The thing that still confuses me is how to remove it from the project? Or does every project have to have one?

BTW, I was amazed to find that xcode does now detect changes to resources and copies them as needed. For example, I had an .obj model that I changed and it knew to just copy that file into the .app when I re-ran the app.

Also worked with the .vert and .frag shaders.

Not sure if it works on binary files, but it is a start.

Thanks again for your help -
Quote this message in a reply
Member
Posts: 72
Joined: 2006.10
Post: #7
Simply go in the properties of your target and set "Prefix Header" to an empty string.

- Sohta
Quote this message in a reply
Member
Posts: 86
Joined: 2008.04
Post: #8
Thanks Sohta - But I tried that. Xcode still seems to want the missing .pch, even with GCC_PREFIX_HEADER = "" and GCC_PRECOMPILE_PREFIX_HEADER= NO.

Maybe it's just broken in this build of xcode? I believe it is the latest 3.1 beta...
Quote this message in a reply
Nibbie
Posts: 1
Joined: 2009.01
Post: #9
I tried renaming a project and had a similar problem with the pch. I renamed all .h and .m files to match the new project name. I changed all text references to them. I cleaned my build directory and changed all apparently related build settings, but there was no way to get xcode to quit looking for that old .pch file. I found a post on another form which said you needed to open the .xcodeproj project file package in Finder ("Open Package Contents") and text edit the .pbxproj file. The old references were still there and I am sure this is what the problem was, but making the edits with a text editor rendered the project file "unparseable" according to xcode. ugly ugly ugly There is probably some middle ground to get this to work?
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Stupid xcode question: How do I turn off precompiled headers? SourceIT 2 6,939 Aug 30, 2008 12:53 PM
Last Post: SourceIT
  Universal headers? Skorche 16 6,801 May 5, 2006 08:17 PM
Last Post: Skorche