开发者

AVCaptureDevice keeps crashing my iPod Touch with OS 3

I made some conditional coding in my app to check for AVCaptureDevice, but it still crashes my iPod Touch (iOS 3.1.3) with this message:

dyld: Symbol not found: _OBJ开发者_运维百科C_CLASS_$_AVCaptureDevice

Referenced from: /var/mobile/Applications/4286D40F-9E33-49AB-9AD9-4F66EB9331A5/TestApp.app/TestApp

Expected in: /System/Library/Frameworks/AVFoundation.framework/AVFoundation

Data Formatters temporarily unavailable, will re-try after a 'continue'. (Not safe to call dlopen at this time.)

mi_cmd_stack_list_frames: Not enough frames in stack.

mi_cmd_stack_list_frames: Not enough frames in stack.

In my code, I do conditional checks like this:

#if (!TARGET_IPHONE_SIMULATOR)
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000 // __IPHONE_4_0
    AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
    // ... more code
#endif
#endif

I'm checking here and the other place in code that uses AVCaptureDevice with this same conditional.

I'm guessing the iPods older iOS version isn't able to link to the newer library, so I how do I correct it?


Try checking if you have AVfoundation.framework added to your Frameworks
In my opinion, it's the most probable reason for the error


First, you cannot use preprocessor directives to select which code to run here. The check has to happen at runtime, not at compile time. So you must use NSClassFromString(), -respondsToSelector: or similar techniques to do this.

Second, to make this compile, change your compiler to LLVM GCC as described by Marco Arment.


AVCaptureDevice is only available on iOS versions 4 and above. You have two options:

  1. Check the system version and handle things appropriately:

UIDevice *device = [UIDevice currentDevice];
if([device.systemVersion floatValue]
    NSLog(@"Not supported on this software version");
}else{

//Proceed Normally
}

  1. Check for class availablility:


Class avcaptureclass = (NSClassFromString(@"AVCaptureDevice"));

if (avCaptureClass != nil){
    //Proceed Normally
}else{
    NSLog(@"Not supported on this software version.");
}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜