XCode 2.2, oh noes!

Sage
Posts: 1,199
Joined: 2004.10
Post: #1
My game does some jiggery pokery with CFBundleGetFunctionPointerForName to give me classloading in C++, and it works great.

The trouble is, I just upgraded to XCode 2.2 and I can no longer run my game from XCode. I *can* run it from the Finder, and it works there. But when I run it from XCode the classloading fails and the app ( by design ) aborts with a message saying it couldn't load class X.

On the status line I see a message about "Executable Runner", which implies to me that XCode is running the executable from some sort of wrapper, which may very well be the source of the problem.

Can anybody point out to me what might be going on, and how to fix it?
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #2
I just put in some debugging code to make certain that the bundle being loaded is in fact the right one, and yes, it is.

So why, if it's loading the right bundle ( the app itself ) is it failing when run under XCode 2.2 and running fine when run via the Finder?
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #3
Try looking in the issues in this document and see if any of the solutions work for you. http://adcdownload.apple.com/Developer_T..._notes.pdf
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #4
I'll read over that. I wrote a mini demo app which shows the problem to be reproducable outside of my app -- and I posted a bug ( with the demo app ) on radar, so I guess I'm doing the right thing here.

Here's the app which shows what I'm talking about.
http://zakariya.net/shamyl/LoaderTest.zip

If you run it from Xcode 2.2 the app will display a message telling you it couldn't alias the function pointer. But if you run it from Xcode's debugger, or by double-clicking it in the Finder, it works correctly.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #5
Good news! It turns out that if you deselect the "Auto-attach debugger on crash" option from the "Debugging" pane of the executable's settings, the functionality works again.

It's a neat feature, but a minor loss.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #6
Hm, that is strange. Is this something you absolutely need? If you only have a few functions to choose from, you don't need to use a fancy function to get the function pointer. If you have dozens or hundreds, I can see your problem, though.

Edit: I just tried getting the function the old fashioned way (by doing bool (*ptr)() = testFunction; after including the file) and it worked fine
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #7
The issue is that my game levels are described in an XML-like file and I use a classloader to instantiate objects based on their descriptions in the file. In such a situation a robust classloader is *infinitely* better than a long chain of string comparisons.

I've got -- right now -- a few dozen object which are classloaded. In the end, I will have probably hundreds. Classloading is a necessity.

Anyway, by turning off the automatic debugger attachment the problem is solved.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #8
Ok, that makes sense. I was thinking it was hard coded rather than an XML file, in which case you wouldn't need string comparisons.
Quote this message in a reply
Post Reply