Recompiling header files in Xcode

Member
Posts: 63
Joined: 2005.12
Post: #1
This is a very simple Xcode question - it's very basic, but I can't seem to find the answer in the docs or online.

The question is, what settings do I need so that Xcode 2.2 will pick up on changes to header files and recompile them when necessary?

I've tried the 'touch' option, but for some reason it seems to be disabled in this particular project; clicking in the 'hammer' column in the project window doesn't do anything, nor does selecting 'touch' from the build menu. Any idea why this might be?

Cleaning and rebuilding works, but the project is too large for that to be a practical solution.

Thanks for any help.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
You don't need to do anything, Xcode will automatically register changes to source files and their dependencies, and rebuild when appropriate.

There were bugs in earlier versions which required the headers to be inside the project directory for that to be the case, or for the headers to be part of the project, but I don't believe that's true any more.

Header files are *never* compiled, incidentally. Only source files are. If you change a header that's not included in any source files, that doesn't affect your program, and therefore doesn't require a rebuild.
Quote this message in a reply
Member
Posts: 63
Joined: 2005.12
Post: #3
Thanks for your reply, OneSadCookie.
OneSadCookie Wrote:Header files are *never* compiled, incidentally. Only source files are. If you change a header that's not included in any source files, that doesn't affect your program, and therefore doesn't require a rebuild.
Sorry, what I meant was that changing the header file does not force source files that include it to recompile.

What appears to be the same problem is discussed here:

http://forums.macrumors.com/showthread.php?t=179562

Which suggests the workaround of making a change to the file that includes the header. This works, but I'd still be interested to know if there's a way to get Xcode to pick up on changes to header files only (or how to enable the 'touch' option for my project).

Thanks again for your help.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
Like I said, you don't have to do anything. Changes will be automatically noticed.

I don't know what could be wrong with your project to cause that though... you didn't turn off indexing or something like that did you?
Quote this message in a reply
Member
Posts: 63
Joined: 2005.12
Post: #5
OneSadCookie Wrote:Like I said, you don't have to do anything. Changes will be automatically noticed.

I don't know what could be wrong with your project to cause that though... you didn't turn off indexing or something like that did you?
I checked indexing, and it's on. It's useful to know that it should work without any special effort though - I'll try making a new project from scratch and see if that fixes it.

Thanks for your help.
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #6
Xcode is broken in the same way for me, despite Keith's insistence that it works perfectly. I was never able to find a solution.
Quote this message in a reply
Moderator
Posts: 691
Joined: 2002.04
Post: #7
@ThemsAllTook: I'll just throw in that Xcode functions properly for me, although I only have installed an older version (1.1) - it became painfully apparent that it was functioning properly for me when I was changing #define values in a header with forty-plus .cpp dependents (painfully because I'm on a 400Mhz box...Cry)

Mark Bishop
Quote this message in a reply
Member
Posts: 86
Joined: 2005.01
Post: #8
Sorry for the bump.

I'm also having this problem with 2.2 -- is it fixed in 2.3?

Newest game: Glow, a sci-fi RPG with lots of zombie bashing. Get it: OS X
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  C++ with SDL2 Framework: Loading .bmp files in same folder in XCode 5 on Mavericks exitcode 1 447 Feb 23, 2014 11:15 PM
Last Post: SethWillits
  Why won't Xcode even try compiling my .cpp files?? SparkyNZ 11 12,877 Apr 3, 2011 01:44 PM
Last Post: AnotherJake
  HTTP header analysis wadesworld 3 3,209 Jan 4, 2009 08:22 PM
Last Post: wadesworld
  Newbie problem XCode Include files BBBert 1 4,147 Mar 17, 2008 03:46 PM
Last Post: OneSadCookie
  .C cplusplus files in XCode? kelvin 2 3,839 Mar 27, 2007 04:18 PM
Last Post: OneSadCookie