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.