views:

206

answers:

3

We have a project that runs fine on OS4 but we're having problems getting it to run on iPad 3.2.

Base SDK is 4.0 and Deployment target is 3.2.

The code crashes on the iPad simulator (and device) before it has even started, with the error

"Data Formatters temporarily unavailable"

It seems to run okay if I take 2 lines out...

AVURLAsset* asset = [AVURLAsset URLAssetWithURL:assetURL options:options];

and

export = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetPassthrough];

I branch according to what OS is present so that these lines never get reached when on a 3.2 device (I know they are OS4), but just them being there at all makes the thing crash out before it even begins.

Any ideas? Cheers

A: 

Try this (or similar):

#if __IPHONE_OS_VERSION_MIN_REQUIRED < 40000
  // code for iOS below 4.0
#else
  // code for iOS 4.0
#endif

Stolen from this question.

godswearhats
I think he will have to upload a single binary to run on 4.0 and 3.2, so the check will have to be at run time, not compile time.
Douglas
Indeed - the same binary for both. The lines I quoted are never even reached if running on 3.2 as I already branch off. What puzzles me is that their inclusion means that the binary will not even start on 3.2.
Paul Carruthers
+3  A: 

First of all, "Data Formatters temporarily unavailable" is a GDB message, it's not why your application crashes. More information regarding this message can be found here.

You need to check the availability of classes during runtime (not compile-time) if you want to write code that runs on both iOS 3.0 and 4.0.

You can do this using the NSClassFromString function like this:

if (NSClassFromString(@"AVURLAsset")) {
    // 4.0 code using AVURLAsset goes here
} else {
    // 3.0 code goes here
}
Can Berk Güder
+2  A: 

If those lines are never reached on the iPad, you may be encountering a problem due to not weak-linking the AVFoundation framework (and potentially others). Because AVURLAsset and AVAssetExportSession don't exist as symbols in 3.2, your application may be crashing on startup on that older OS.

I describe how to weak-link a framework in response to a similar problem in this answer.

Brad Larson
Spot on Brad! That fixed it straight away.
Paul Carruthers