Geoff Garside

Jan 04 2009

Apple Wish: Xcode Building Embedded Projects

I’ve been spending quite a lot of my time recently using Apple’s Xcode just hacking on things which scratch a bit of an itch I get from time to time. Mainly I’ve been working on developing Mac OS frameworks for a couple purposes and I recently wanted to make a GUI demo app which used my framework, so I created a new project and use a git submodule to import the framework project. This all worked just fine, I was able to hook in the framework project to the demo project, set up the framework as a dependency of the GUI app and slapped the old Build button and got two errors.

Seems Xcode first builds the framework into Framework/build/Debug/Framework.framework and then the GUI app into build/Debug/Gui.app which means the GUI app can’t find the framework to get the headers from.

What are our options?

Well what is required is for the build directories of both projects to be the same. You’ve got a couple of choices here. You can set an Xcode wide preference and build all projects into a specific directory, or you can set the build directory in each of the projects (or just one) to make them the same. Lets explore the latter for the sake of argument as its the least disruptive to other projects.

Option 1

The first option, which is advocated in Xcode 3 Unleashed, is to place the two projects in the same directory. In this case you have two .xcodeproj files in your project directory, which therefore use the same build directory. The downside to this method is that it doesn’t work terribly well with git submodules as each submodule has to exist as a separate folder.

So because of the requirement to use git submodules this method isn’t really that feasible.

Option 2

A second option might be to change the sub project to build into ../build which is the build directory of the primary project. This has the benefit of keeping the build results in the logical place of the primary project. The down side is that you have to modify the submodule in order to make it work. While in most cases if you git pull on the submodule to update the source it shouldn’t break it but it is a nuisance none the less. So for this reason I also don’t really like this option either.

Option 3

The final option would be to change our GUI project to use the build directory to use the build directory of the framework project. This keeps us from having to modify the submodule but I personally don’t like this solution as it means our primary project in this case is building into the space of a sub project.

What would be better?

So why is this a wishlist item? Well I’d personally like to be able to override the sub project build directory in the primary project. So you’d be able to Get Info on the Framework.xcodeproj in your Groups & Files pane and change the build directory. This would then either build the sub project and then copy those contents into the primary projects build directory, or else just have the project when its being built by the primary build into the primary build directory.

Update: A Stop Gap

Played around a bit further and I believe the Frameworks Search Paths build configuration setting is possibly an appropriate solution. You can set this to say Framework/build/Debug for your Debug configuration and then the compiler can find your framework project correctly for compiling. All the changes are happily in your primary project and it makes sense that it should have to search into the Framework directory for the right files. I’m a bit happier now :-)

Comments
blog comments powered by Disqus