'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named UIKeyCommand' - objective-c

My app is crashing when I try to display another view controller. It does work correctly when the iOS SDK is set to 7.0 and I am targeting iOS 7.0. But I need the app to target iOS 6.0. UIKit is (obviously) declared in the imports. The UITableViewController I am trying to present works perfectly fine as far as I'm aware - I created it for another app, using XCode 4.6.3, targeting 6.0 and it compiled without error (as does this one) but it also displays without crashing.
I could provide code, code which does nothing more than present the table view controller using a modal transition, but I even went to the point of connecting a UIButton to the UITableViewController - it worked on iOS 7, but not 6. It's my belief that when I compile with the iOS 6.1 SDK, it should be using iOS 6.1 frameworks?
UIKeyCommand is only available in iOS 7 and later, according to this. That gives me reason to believe that it is using the iOS 7.0 frameworks even though the iOS 6.1 SDK has been specified.
I've tagged this with the xcode tag as I believe it could possibly be caused by xcode incorrectly searching for the specified SDK's frameworks.

I had the same problem as you and here is what i did to solve it:
I opened the Storyboard as Source Code and searched for the tag : keyCommands , I found a tag similar to
<keyCommands> <keyCommand/> </keyCommands>
and i deleted it.
After that i runned the app in iOS 6 & 7 and it worked with no problem.
Let me know if this works on your app too!
Cheers!

Related

import CallKit crashes randomly on iOS 9

I have imported CallKit framework as optional only. But import CallKit crashes while running on iOS 9 at launch. But works perfectly on iOS 10.
It worked fine in XCode 8 beta 6 but this issue is happening only on XCode 8.
The code is in Swift 3.
Any help is much appreciated.
CallKit API is only for iOS 10.0+. It won't work for iOS 9.0. Use a condition for iOS version 9.0 and 10.0 to avoid the crash.
Reference : https://developer.apple.com/reference/callkit?language=objc
There is/was a bug in Swift 3 language that wrongly links module libraries github pull request, that is fixed now, but the fix is not yet implemented in XCode, not even in beta.
You could get latest swift toolchain build from link and install it to XCode to try and see the fix, but the app would not be approved for Appstore as it's stated here
You got two solutions;
wait for apple to release XCode with new version of swift 3.0.2+
or revert your code back to swift 2, where it works, with "Use Legacy Swift Language Version" flag in Build Settings
If you choose to revert back to swift 2, brace yourself with a lot of patience :D

Import LocalAuthentication.framework crashes on iPhone5s with iOS 7.1

This question has been asked here before but the selected answer and comments does not resolve the problem. So I am asking it again and going to keep it simple.
I have an app in which am using Touch ID. It works fine in all devices except iPhone 5s with iOS 7.1.
To observe this thing.
Create a new Xcode project.
Add the LocalAuthentication framework.
Observe that the app crashes right away in iPhone 5s with iOS 7.1.
Now mark LocalAuthentication as optional but it still crashes on that specific device.
Note: I also set Link Frameworks Automatically to NO in build settings. Then I had to add "UIKit" framework to app manully. Apart from that I did nothing.
I also tried the same thing with apple sample code, it is also crashing for the same.
Crash Log:
dyld: Symbol not found: _objc_isAuto
Referenced from: /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/usr/lib/libobjc.A.dylib
in /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
Please suggest something.

interface orientation in iOS6

I have to make some changes in an existing app. That app was last update in June when iOS6.0 was not launched. I am wondering how the orientation works properly on the devices running with iOS6.0?? As that build contains deprecated methods of oreintation?
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
This method doesnt get called in iOS6.0 then how that app in app store is working fine in iOS6 devices? Additionally if i run this app from xcode using its code, then it doesnt support orientation for iOS6. Now my client is saying app on app store is working fine with orientation in all the devices and the new build is not supporting orientation. I know I can fix this issue by using new methods for orientation
-(BOOL)shouldAutoRotate
but just curious to know how older app is working fine on iOS6 devices using deprecated methods when those method are not even getting called in when i run it using xcode.
The older applications were compiled using iOS 5.x SDK, that's why they can run fine on iOS 6, the problem occurs when you compile non iOS 6 compliant code with iOS 6.x SDK.

iPhone Simulator versions below 6.0 no longer appear in Xcode 4.5 scheme drop down

Newbie questions. While learning Objective-C using Xcode 4.5.3 and the book Programming In Objective-C 4th edition, I have reached the final chapter in which two iPhone apps are built. Before building the apps I downloaded iOS simulators 4.1, 5.0 and 5.1.
When I built the first simple iphone app I was able to select iphone 5.0 simulator in the scheme. When I built the second, more complex app I tried to change the scheme which had defaulted to iPhone 6.0 simulator back to iphone 5.0 simulator only to find that that no simulator below 6.0 is available in the drop down any longer.
Having shrugged my shoulders and allowed the launch of my app in the 6.0 simulator I found that one row of the buttons do not display properly in the simulator. This row appears on top of another row with their labels blank or '-'. The xib for this project was created entirely visually according to the book's instructions as I do not yet know how to programatically code the user interface.
I have two questions:
How do I test this app in the iPhone 5 simulator if this scheme is no longer available in the scheme menu;
Why does the iphone 6.0 simulator fail to resemble the xib?
First of all, be sure that you have the Simulator downloaded for 5.0 and 5.1, for this, go to "Xcode -> Preferences -> Downloads", and you will see it there.
If you have them, the next step is to check that your project is deployed in those versions. For this, go to your project properties (click in the project in the project navigator) and check the Property "iOS Deployment Target" in the Info tab.
Next step, in the same screen click in your target and check the tab "Build Settings", and check the property "Base SDK" to see which iOS version you have there.
Let me know how it goes!
This is in answer to my second question:
Why does the iphone 6.0 simulator fail to resemble the xib?
Autolayout. Once this option is unticked, display is as expected.

Library not loaded

I added Social.framework in my application in the same way i use to add the other frame works. I have downloaded xcode 4.5 and iOS 6 . but my application crashes with follwing error only on device. It works fine on simulator.
dyld: Library not loaded: /System/Library/Frameworks/Social.framework/Social
Referenced from: /var/mobile/Applications/FC88291D-2052-45D6-A7BB-65CE340F07BF/Uploading Image.app/Uploading Image
Reason: image not found
I was getting this exact error. My app currently has a deployment target of 5.1. I wanted to add Facebook sharing. I found this old post, Conditionally including a library for different iOS SDK versions?. All I did was set "Social.framework" to 'optional' and it did the trick, then my app would run on ios 5.1 and ios 6.0. Of course you need to do checks at runtime for what OS the device is running otherwise you could run into a crash if you try to access social.framework in ios 5.1 or earlier. Hope that helps!
In Xcode go to targets, Go to build phase and search for Social frame work you will find that under "Link Binary with Libraries" section. There select social frame work and see there is an option on right hand side required/optional in that just change required to optional. Now you are able to run on all ios devices without any crashes.