NSApplication subclass crashes on 10.3 with Xcode 3
NSApplication subclass crashes on 10.3 with Xcode 3
- Subject: NSApplication subclass crashes on 10.3 with Xcode 3
- From: Kevin Wojniak <email@hidden>
- Date: Tue, 16 Sep 2008 23:18:53 -0400
I'm working on an app that was recently brought over to Xcode 3 from a
2.X version. The app uses an NSApplication subclass that's in a
framework, and crashes upon startup on 10.3 when using the Xcode 3
build. However, with Xcode 3/10.5 and Xcode 2.5/10.3, it works.
I've successfully duplicated the error in a separate project that
consists of an empty application (no extra code) and a framework with
only an NSApplication subclass, which is used as the principle class
in the app's Info.plist:
<key>NSPrincipalClass</key>
<string>MyApp</string>
The code (in the framework) - it's virtually identical to what's
crashing in the main app:
@interface MyApp : NSApplication
@end
@implementation MyApp
+ (void)initialize
{
NSLog(@"MyApp initialize!");
NSDictionary *dict = [NSDictionary dictionaryWithObject:@"object"
forKey:@"key"];
NSLog(@"dict: %@", dict);
}
@end
It fails on 10.3 in this sample project after the first NSLog:
Exception: EXC_BAD_ACCESS (0x0001)
Codes: KERN_PROTECTION_FAILURE (0x0002) at 0x00000020
Thread 0 Crashed:
0 libobjc.A.dylib 0x908611ec objc_msgSend + 0xc
1 com.apple.Foundation 0x90a2c488 -
[NSPlaceholderDictionary initWithObjects:forKeys:count:] + 0xb8
2 com.apple.Foundation 0x90a63710 +[NSDictionary
dictionaryWithObject:forKey:] + 0x44
3 com.yourcompany.SomeFramework 0x0000eea8 +[MyApp initialize] +
0x68
4 libobjc.A.dylib 0x908629e0 class_initialize + 0x140
5 libobjc.A.dylib 0x90861524
_class_lookupMethodAndLoadCache + 0x84
6 libobjc.A.dylib 0x90861298 objc_msgSend + 0xb8
7 com.apple.AppKit 0x92f696d0 NSApplicationMain +
0x13c
8 com.yourcompany.PantherTest 0x00001e44 main + 0x38
9 com.yourcompany.PantherTest 0x00001a30 _start + 0x2f8
10 com.yourcompany.PantherTest 0x00001734 start + 0x30
My guess is something is different with the linker that is
incompatible with NSApplication subclasses inside a framework.
If I move the NSApplication subclass to the main app, it works but
there are other weird crashes that are similar.
We'd rather stick with Xcode 3 instead of going back to Xcode 2.5 if
possible. Does anyone have an idea with what's going on?
Kevin
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden