views:

771

answers:

4

Hello, all. I've been banging my head for a few hours because of this problem. I have a universal project that's a mix of iPhone and iPad projects. I put these codebases together into the universal project and, after a lot of "#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 30200" checks, got the project to run in both the iPhone (OS 3.0 to 3.1.3) and iPad simulators. After doing a more finagling with the project settings of external libraries that I load, I got the app to load on an iPhone (which runs OS 3.1.3).

However, when I run the app on my iPad, I get an immediate SIGABRT error. I've tried running it under Debug, under Release, with Active Architecture of both armv6 and armv7. I've checked and double-checked that the app has the right nib files set up (but, again, this app runs fine in the simulator). I've gone through the external libraries I'm using and set them up to have the same base SDK (3.2), same architectures (Optimized (armv6 armv7)), the same targeted device family (iPhone/iPad), and the same iPhone OS deployment target (iPhone OS 3.0).

So, to summarize... I have a universal app that works in the simulator for iPhone and iPad, runs on an actual iPhone, but doesn't run on an iPad. It doesn't get far on the iPad -- there's an immediate SIGABRT error that stops execution. Help??

Edit Following Jason's suggestion below, here's the stack trace of my app:

#0  0x30c8e0a0 in __kill ()
#1  0x30c8e096 in kill ()
#2  0x30c8e088 in raise ()
#3  0x30ca2210 in abort ()
#4  0x32944a22 in __gnu_cxx::__verbose_terminate_handler ()
#5  0x335657ca in _objc_terminate ()
#6  0x32942df4 in __cxxabiv1::__terminate ()
#7  0x32942e48 in std::terminate ()
#8  0x32942f18 in __cxa_throw ()
#9  0x335646aa in objc_exception_throw ()
#10 0x32c91c9c in -[NSException raise] ()
#11 0x32b57db2 in -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] ()
#12 0x32b1b9da in _NSSetUsingKeyValueSetter ()
#13 0x32b1ae40 in -[NSObject(NSKeyValueCoding) setValue:forKey:] ()
#14 0x32b1adac in -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] ()
#15 0x315db6b6 in -[UIRuntimeOutletConnection connect] ()
#16 0x32c27bc6 in -[NSObject performSelector:] ()
#17 0x32c25a18 in -[NSArray makeObjectsPerformSelector:] ()
#18 0x315d5746 in -[UINib instantiateWithOptions:owner:loadingResourcesFromBundle:] ()
#19 0x315d53c0 in -[NSBundle(NSBundleAdditions) loadNibNamed:owner:options:] ()
#20 0x314d5d50 in -[UIApplication _loadMainNibFile] ()
#21 0x314d5a7e in -[UIApplication _runWithURL:payload:launchOrientation:] ()
#22 0x31521962 in -[UIApplication handleEvent:withNewEvent:] ()
#23 0x315212e0 in -[UIApplication sendEvent:] ()
#24 0x31520d2a in _UIApplicationHandleEvent ()
#25 0x30d62b32 in PurpleEventCallback ()
#26 0x32c23d9c in CFRunLoopRunSpecific ()
#27 0x32c234e0 in CFRunLoopRunInMode ()
#28 0x314d54a8 in -[UIApplication _run] ()
#29 0x314d39f2 in UIApplicationMain ()
#30 0x00002f62 in main (argc=1, argv=0x2ffff5d8)

As you can see, it doesn't get out of the main function in main.m.

A: 

This looks like you have some connections in the main Nib-file which points to non-existing outlets in the code being loaded. Make sure you load a Nib-file which match the platform and which is in synch with the code being loaded.

If you are removing some outlets in your code by means of #if __IPHONE_... make sure you don't have the Nib-file trying to reference this outlet.

Claus Broch
Ah, thank you, Claus. You got me looking down the right path. It turns out that my "`#if __IPHONE_...`" checks don't work as I expected. I wanted to use them for iPad-specific classes, to be ignored when running on an iPhone. For what it's worth, here's what I had: "`#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 30200`" and here's what you need: "`#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200`"Argh, such an idiot. Heh, at least I got it figured out. :)
donkim
A: 

This probably doesn't help with your problem, but if you're trying to create a universal binary, then using #if won't work. A universal binary should contain code for both iPhone and iPad and make the determination at run-time as to which device it's running on, like so:

if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad )

In addition, your conditional compile is only checking that the version is at least 3.2. When iPhone OS 4.0 is released for both devices, then you will get code for iPad-only features included in the iPhone build.

Brian
Yeah, I was wondering about that. I need to figure out how to handle things like declaring that a class conforms to, say, UIPopoverControllerDelegate. My hope is that Apple allows you to combine separate iPhone and iPad binaries and call them "universal."
donkim
A: 

For handling specific Classes, Try (Jarad P's Solution) found in stackoverflow, which list:


..."Apple's recommendation for universal apps in the iPad Programming Guide, if you want to build for multiple OS versions with inconsistent APIs, you should use NSClassFromString, and go from there. This way, you only have to have one target (the lowest OS you support) and through out your code have things like

Class mplayerControllerClass = NSClassFromString(@"MPMoviePlayerViewController");
if(mplayerControllerClass != nil) {
   //Code for 3.2, e.g. [mplayerControllerClass alloc]
} else {
   //Code for pre-3.2 OSes
}
Newbyman
A: 

hey i m also getting same type of error it doesnt come out of main function.it stops at int retVal = UIApplicationMain(argc, argv, nil, nil); can anyone help me...

Sneha Patel