Tesugen

Xcode Project With Multiple WebObjects App Targets

This is of limited interest, but perhaps it will be useful to someone. I didn’t find anything about this when googling.

I have a hand-rolled Xcode project, containing two WebObjects application targets and one for a Cocoa app. There’s nothing strange about this, I thought, but WebObjects stubbornly loads all resources from the project in rapid-turnaround mode, regardless of whether they belong to the target or not. So if you have components with the same name in both apps, your app might try to load it from the other target.

After spending a lot of time trying to figure this out, I realized that there was no other way than to hack WebObjects. So what I did was to fiddle with a member variable of private class _WOProject, like this:

First, you need to create a class with a static method within the package com.webobjects._ideservices, in order to gain access to the package-scoped member variables.

You’ll need to get hold of the _WOProject instance for your open Xcode project. It should be listed in the _WOProject._openProjects dictionary. If you invoke the hack first thing in the Application constructor, it should be there.

This object has a dictionary named _resourceNameToPath, which is keyed on the resource name, say MyPage.wo, and has as value a dictionary which I guess is keyed on the languages supported by your app. I haven’t localized anything yet, so the only entry has an empty string as key.

So for each resource that might be pointing to the wrong target, replace the entry in the dictionary with one pointing to the correct resource.

I’ve uploaded some sample code to illustrate what I do.

The above was posted to my personal weblog on December 15, 2004. My name is Peter Lindberg and I am a thirtysomething software developer and dad living in Stockholm, Sweden. Here, you’ll find posts in English and Swedish about whatever happens to interest me for the moment.

Posted around the same time:

The seven most recent posts:

  1. Tesugen Replaced (October 7)
  2. My Year of MacBook Troubles (May 16)
  3. Tesugen Turns Five (March 21)
  4. Gustaf Nordenskiöld om keramik kontra kläddesign (December 10, 2006)
  5. Se till att ha två buffertar för oförutsedda utgifter (October 30, 2006)
  6. Bra tips för den som vill börja fondspara (October 7, 2006)
  7. Light-Hearted Parenting Tips (September 16, 2006)
Bloggtoppen.se