I am getting the following error while running an app on iOS simulator 4.2/4.3. It's working fine with iOS 5.
dyld: Library not loaded: /System/Library/Frameworks/Accounts.framework/Accounts
Referenced from: /Users/User/Library/Application Support/iPhone Simulator/4.3/Applications/FBFD053F-E816-4114-AFEB-D90A6A67259B/SampleApp.app/SampleApp
Reason: image not found
I am using the AssetsLibrary and OpenCV frameworks in my app.
I am not getting the cause of error.
Better yet you could keep it but change it from Link Binary With Libraries: from required to optional.
Then in your code skip the framework methods when in a 4.x device.
You are getting this error because Accounts.framework is only available in iOS 5.0 or later. So you are not able to run it on iOS 4.2/4.3.
You can also mark Accounts.framework as optional. In Xcode, select Targets > Build Phases > Link with binary libraries > Accounts.framework and mark as optional.
Also please make sure to skip this code(code that requires iOS 5.0 or greater) in iOS 4.3. You can use the following code to check this :
NSString *reqSysVer = #"5.0";
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending) {
//Add any code that requires iOS 5.0
}
Related
I have created UITableView project in XCode 4.6 with iOS 6.1 SDK, and set target sdk to 5.1, when the app calling dequeueReusableCellWithIdentifier in cellForRowAtIndexPath function, the app throw a exception, the simulator is 5.1, on simulator 6.x is ok.
1:
[UITableView dequeueReusableCellWithIdentifier:forIndexPath:]: unrecognized selector sent to instance
2:Terminating app due to uncaught exception NSInvalidArgumentException, reason: -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:]: unrecognized selector sent to instance
1. dequeueReusableHeaderFooterViewWithIdentifier
Availability
Available in iOS 2.0 and later.
-> Minimum iOS version required to run this function is iOS 2.0
2 .dequeueReusableCellWithIdentifier:forIndexPath:
Availability
Available in iOS 6.0 and later.
-> Minimum iOS version required to run this function is iOS 6.0
EDIT
IF your want to use this function the you can check your current device version and then implement this
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
NSLog(#"curr version = %f",[currSysVer floatValue]);
if ([currSysVer floatValue] >= 6) {
//iOS 6.0 and later code
// dequeueReusableCellWithIdentifier:forIndexPath:
}
else{
//dequeueReusableHeaderFooterViewWithIdentifier
}
If you look at the Apple documentation, you'll see that dequeueReusableCellWithIdentifier: forIndexPath: came in with iOS 6.0.
That means if you try to call this method on iOS 5.X devices, it's going to throw an exception.
It would be better if you used the older "dequeueReusableCellWithIdentifier:" call if possible.
One big difference between the two calls is that the latter (older) one can return nil, in which case you need to alloc/init a new reuseable cell.
I have an universal iOS app, giving efforts to make it compatible with iOS 6. I am using Cordova / Phonegap framework so my app is HTML, CSS and JS. I am using calenderPlugin for Cordova which is available on GitHub, working fine before iOS 6.
Issue starts here:
Apple added that, from iOS 6 onwards, before doing any operations on calendars and reminders, we need to grant a permission from user. for that here is the sample code:
EKEventStore *eventStore = [[EKEventStore alloc] init];
if( [self checkIsDeviceVersionHigherThanRequiredVersion:#"6.0"] ) {
[eventStore requestAccessToEntityType:EKEntityTypeEvent completion:^(BOOL granted, NSError *error) {
if (granted){
//---- codes here when user allow your app to access theirs' calendar.
}else
{
//----- codes here when user NOT allow your app to access the calendar.
}
:
:
}];
}
//**********************************************************************************
// Below is a block for checking is current ios version higher than required version.
//**********************************************************************************
- (BOOL)checkIsDeviceVersionHigherThanRequiredVersion:(NSString *)requiredVersion
{
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
if ([currSysVer compare:requiredVersion options:NSNumericSearch] != NSOrderedAscending)
{
return YES;
}
return NO;
}
Of course I have added EventKit.Framework and EventKitUI.Framework. Now the thing is,
for development of iOS 6 I downloaded and installed xCode 4.5 which comes with iOS6 SDK.
xCode does not find out this method requestAccessToEntityType, neither the constant EKEntityTypeEvent is available.
It seems I am missing EventKit.Framework for iOS 6, but how? I have xCode 4.5 which came with SDK for iOS 6. Any suggestions?
Issue Solved,
I have added EventKit.framework by right click on frameworks under project and add files to project. these frameworks was for iOS 5. To add framework for iOS 6, first I removed this frameworks from my frameworks folder and then went to Targets > Summary > Linked Frameworks and Libraries. there I pressed + and added EventKit.framework appearing under iOS 6 folder.
Cheers :-) happy coding.
Check with your BaseSDK, because I have no problem using it in XCode4.5 with iOS6 SDK. I upgrade my XCode 4.5 via App Store, not from development site though.
I have developed an application using last SDK (4.3) and XCODE 4. I have tried this application on iPhone 4 and 3GS but always with IOS 4.3 on them.
Now I try to test my application on a 3G Iphone with IOS 3.1.3. To to that I declare "IOS Deployment Target" to be 3.1.
But their are compilation errors for the following pieces of code :
UIDevice* device = [UIDevice currentDevice];
BOOL backgroundSupported = NO;
if ([device respondsToSelector:#selector(isMultitaskingSupported)])
backgroundSupported = device.**multitaskingSupported**;
if (backgroundSupported)
[request setShouldContinueWhenAppEntersBackground:YES];
Compilation error : "Request for member 'multitaskingSupported' in something not a structure or union
And : "ASIFormDataRequest may not respond o ' - setShouldContinueWhenAppEntersBackground'
if ([[UIApplication sharedApplication] respondsToSelector:#selector(applicationState)] && [[UIApplication sharedApplication] applicationState] == **UIApplicationStateBackground**) {
...
}
Compilation error : "UIApplicationStateBackground undeclared first use in this function)
I do want to keep these behaviors for IOS4. How can I manage to have this compiled for target 3.1 ?
Thanks for your help !
kheraud
Make sure that, in your project or target info box, you have Base SDK set to iOS 4.2, and iOS Deployment Target set to iOS 3.1. It sounds to me like your Base SDK is set wrong.
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: _OBJC_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:
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
}
Check for class availablility:
Class avcaptureclass = (NSClassFromString(#"AVCaptureDevice"));
if (avCaptureClass != nil){
//Proceed Normally
}else{
NSLog(#"Not supported on this software version.");
}
i'm trying to add printing features to an ios app.
while printing itself works fine, and the app works on ios > 4, i haven't figured out yet how to keep the ios 3.1 compatibility...
i guess the issue is this: completionHandler:(UIPrintInteractionCompletionHandler)
A block of type UIPrintInteractionCompletionHandler that you implement to handle the
conclusion of the print job (for instance, to reset state) and to
handle any errors encountered in printing.
once i add the block:
void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) =
^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
};
the app won't even launch on iOS 3.1
probably because blocks aren't available there.
yes, i made sure that this code won't be run when launched on iOS 3.1...
if (([[[UIDevice currentDevice] systemVersion] floatValue] >= 4.2) && ([UIPrintInteractionController isPrintingAvailable]))
so i wonder if there's a way to have printing support for iOS >4.2, but keeping it to run on iOS 3.1?
maybe there's a way to use a method instead of the "block"?
or how would be the correct way to have printing available on supported iOS devices, and remain backwards compatible to iOS 3.1?
just add -weak_framework UIKit to the project settings under "Other Linker Flags" and make sure you use conditional code for printing API.
Conditional code should check feature availability, not OS version:
if (NSClassFromString(#"UIPrintInteractionController")){
void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) =
^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
};
}
Set your project target to iOS 3, and you're good to go.
The best practice for detecting if AirPrint is available is to use NSClassFromString. If you use this method in general, then you always know if exactly the class you want is available, without having to hard-code which features correspond with which version. Example code:
Class printControllerClass = NSClassFromString(#"UIPrintInteractionController");
if (printControllerClass) {
[self setupCanPrintUI];
} else {
[self setupCannotPrintUI];
}
That way your app can still work on previous iOS versions, although it won't be able to print from them.
I've been able to use this technique and run it on an iOS 3.0 device without any problems with the block code (the ^-based stuff). In my build settings, I have the Base SDK set to iOS 4.2, and the Deployment Target set to iOS 3.0.
I posted a sample Xcode project at the end of this blog post on printing in iOS. This is the project that successfully runs for me on a device with iOS 3.0 and another device with iOS 4.2. You may have to change the bundle identifier in the info.plist to get the code-signing to work for you, but that's independent of the printing stuff.
Set Deployment Target in your Project Settings to iOS 3.x. However, set the Base SDK to 4.2. Now you can use the 4.2 classes and iPhones running 3.x can install your app too.
Keep in mind that when you use a 4.2 class on an iPhone 3.x, the application will crash (so keep checking the system version on-the-go).
NSComparisonResult order = [[UIDevice currentDevice].systemVersion compare:#"3.2" options: NSNumericSearch];
if (order == NSOrderedSame || order == NSOrderedDescending && [[UIDevice currentDevice]isMultitaskingSupported]) {
// >4.2
}
else {
//< 4.2
}
Note:
also change UIKit framework setting from "required" to "weak" this will help you to run application on iOs < 4.2 as well as iOs >= 4.2