On Oct 28, 2006, at 3:56 PM, Robin Mair wrote: Scenario 1: I'm happily coding away in Xcode with my large C++ framework that I'm working on and I decide I need to add a new data member to one of my classes. So I add the data member and some accessors for it and then go and build my project. It seems to build fine but when I go to run it all hell breaks loose and my application starts misbehaving very badly! So I comment out my newly added data member and build and run the code again, viola works fine!
Yes! I do know what is going wrong here but my question is why? Why do I have to go and throw away my build folder and possibly my precompiled headers and who knows what else in order for Xcode to figure out it needs to get rid of this stuff and recreate it all. I mean I thought this is what an IDE was supposed to do, why do I have to do all of this groveling in order to get such a simple addition to build successfully.
My understanding of a development environment is that it is supposed to manage all of this dependency tracking and do the right thing! Xcode seems to have a very hard time getting dependencies right a some of the time. I end up wasting large amounts of time trying to decipher why it is hosed, with the only solution being throwing away anything it has produced. At the very least give me a "Clean All" that would really do what it says and get rid of everything!
Now granted it could be my fault in that I do not have something setup correctly, but should I really have to be setting something up to have something this fundamental work correctly?
Scenario 2: I have quite a few static C++ libraries [7] included in my projects, but whenever I open a project Xcode seems to have them all messed up. If I want to do a DEBUG build it shows all of the libraries as being a mix of DEBUG and RELEASE, of course trying to switch between the two does nothing. The only way I can work around the problem is I have to do a build and let it fail, then when I switch between DEBUG and RELEASE the libraries will be updated correctly. Is this a known problem or am I doing something wrong, it has certainly been in all of the recent versions on Xcode that I have tried.
Then there is a question about the preference that is supposed to SAVE ALL files before building, why does xCode not ALWAYS save all files before building, it seems to have some decision process where by it does not save ALL of the files, why?
Hopefully some kind person on this mailing list will enlighten me as to why Xcode seems to be a little sloppy at these very fundamental tasks that one should take for granted with an IDE. Or show me where I'm the one to blame and not the tool!
A quick question that may get to the bottom of both issues: do you have your framework created by one project and your application created by a second project? And if so, have you set up a dependency between the application and the framework it uses?
If you haven't, that would explain both circumstances. In the first, if you rebuild the framework, you need to recompile the app against its changed headers and relink it against the changed library. If you rebuild the framework with different data members in a class, the app will indeed crash. And rebuilding the library does not itself force a rebuild of its clients—though when you rebuild the app it should be smart enough to only rebuild those parts that are actually affected by the framework change.
For the second scenario, how did you add the libraries to the project (and do you name the debug and release libraries differently?) Xcode works best in such circumstances when your projects are set up like this:
- related projects share the same build products directory - related projects have a common set of configuration names - you let Xcode generate build products in the per-configuration directories - you don't alter the name of your build product per-configuration
So if you build the Debug configuration of your app, it notices it needs the Debug configuration of a library, loads and builds that project, its output goes into "foo.a" or whatever in the Build Products/Debug directory, and when your app builds, it links with Build Products/Debug/Foo.a.
If you have brought over separate Foo.a and Foo Debug.a libraries, it takes more work to get Xcode to look for the right link library in the right configuration. If you just drag and drop, say, Foo.debug, then Xcode will look for that library in both configurations. You can set it up to work manually, but it's a lot more work.
And for the save-all question, save-all-and-build only saves files in the current project, not dependent projects. Yes, this could work better. But in general, if you have a dependency chain of projects, build them all from the bottom project to the top and the Save Alls will do the right thing. One way to streamline this is to use multiple targets in the same project: have one project build both the framework or static library in one target, then the app itself in another. All the depdencency checking, Save All, and intermediates will all be coherent, and things will act as you expect.
Chris
|