On May 22, 2013, at 10:34 , Brian Syme < email@hidden> wrote: But I have an annoying problem. During the build static library public headers are copied to a location in the derived data directory. Occasionally I end up opening this copy of the header in Xcode (probably by right clicking on a type declared in the header and selecting Jump To Definition.) I sometimes forget this (Xcode doesn't make it particularly obvious that I'm looking at the copy - a slightly different jump bar path is the only difference) and make changes to the copy, which are promptly overwritten by the next clean build. Annoying, to say the least.
So I'm looking for possible solutions to this. Ideally Xcode would know to open the original and not the copy (somehow) but I would settle for just making the copy read only in Xcode as a way to guard against editing it. I suppose I could do this with a custom build step.
You shouldn't really be adding files from a derived data directory to your main project. The derived data is (by design, as I understand it) intended to be a throwaway intermediate set of files.
Instead, add the library project to your main project's workspace, and add the library's product to the main project's Link With Binaries build phase. That way, if you edit any library public headers, you're editing the files in the real library source folder(s). Then Xcode (in effect -- it may take some shortcuts transparent to the build process, in your normal debugging workflow) will re-build the library for you, and recompile main project files that depend on the library header files. Using this approach also allows Xcode to use the appropriate library configuration (Debug, Release, etc) if you switch configurations for the main project.
If you need to build a distributable library separate from the main project, use Project --> Archive on the library target.
|