Unrecognized selector UIDeviceRGBColor countByEnumeratingWithState:objects:count: - ios

I know this is kind of a dupe, but I don't have enough reputation yet to comment on the original post and, while I don't have an answer, I do have more useful information (a concrete example). Moderators, feel free to move this to the proper location.
When compiling my code using the latest XCode 8 beta 6 (iOS 10 SDK), I get an exception "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIDeviceRGBColor countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x600000071340'"
This happens during the call:
auto viewController = [[[UIViewController alloc] initWithNibName:#"ViewController" bundle:nil] autorelease];
I have isolated the problem by whittling down my project to the bare minimum that will compile and still exhibit the problem. You can download it here:
Example project
Note that I took out lots of code, nearly all classes are gone, which results in a lot of warnings (not errors) for nonexistent classes referenced from the xib. But that doesn't matter, the code still compiles and runs just fine with the iOS 9 SDK. After compiling with the iOS 10 sdk, however, it crashes both in the simulator and on devices running iOS 9.
You can work around the problem by changing "#if 0" into "#if 1" in the file "HackForUnrecognizedSelectorInIOS10.m". This adds a category defining the missing selectors for UIColor. But obviously you can't add that to shipping code, it's just a temporary stopgap measure to continue developing.
I filed a bug report (28153870). But if anyone has any more information on how to avoid this problem without ugly hacks, any information is welcome.
Thanks
Michel Colman

When I try to compile and run my project with the same configuration (XCode 8 beta 6, iOS 10 SDK), I encountered a similar issue, except that my error message was:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIDeviceRGBColor length]: unrecognized selector sent to instance 0x600000479280'
And I noticed that this issue only occurs when the view is init by using interface files, i.e. Xib and Nib. I solved this issue by:
Open your interface file, in the right panel, navigate to the File Inspector tab.
Change the attribute highlighted to "iOS 7.0 and Later" (or whatever iOS version later)
Then compile and run your project again, this should fix your issue, though I am not sure about the reason behind this. I tried the same with your sample project and it solves the issue too.

In my case, I needed to change the project deployment target to 8.0 in the product general settings. Thanks to the hint from the accepted answer!

Related

iOS Wikitude SDK crash on exit/reopen app

I've developed a simply app for iOS and Augmented Reality (with WikitudeSDK).
All go fine, but when I exit and reopen the app, at times the app crashes with the following message:
Assertion failure in -[WTGCDDriver createSharedContextWithId:], /Users/emperor/Development/Tools/Jenkins/Master/Instance/jobs/architect_sdk_builder/workspace/repositories/ios_core_services/src/Rendering/Driver/WTDriver.mm:71
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: _context'
Have you any idea of this?
Thanks.
For some reason the OpenGL context is null when you reopen your app; you receive this error because we seem to have forgotten to disable assertions for a public build. So thanks for making us aware of this oversight.
With respect to the actual issue, I cannot provide an answer without having more of an insight into what exactly your app is doing and which version and configuration of the SDK you are using.
I'd therefore like you to create a thread in the Wikitude forums which provides a platform that is better suited for assisting you with this issue than Stack Overflow is.

App began to crash on iOS 9.1 Beta 2

The application began to crash when installing on iOS 9.1 Beta 2. Exactly same binary (downloaded from hudson link) behaves so:
It did not crash on iOS 9.0 and iOS 9.0.1
It did not crash on either iOS 8
I have extracted the crash log, crash happens inside the call to [[NSBundle mainBundle] loadNibNamed:#"NameOfView" owner:self options:nil];. The crash itself is NSUnknownKeyException:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[< NameOfView: 0x1446a6ea0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key .'
So far i see weird key '.' which nib loading mechanism tries to set on my class, and obviously, such is not present in nib. And this looks extraweird even more, due to iOS 9.1 beta 2 is the only version with this behaviour. Moreover, building app with XCode 7 from on same git revision gives no success crashing app - it works as expected. Has anybody experienced such behaviour after trying your release versions on iOS 9.0.1 beta 2? Want to have some feedbacks of SO community before file a bug to radar. Appreciate your help, guys.
P.S. I'd like to emphasize that the issue reproduces only on that particular binary. Building it again from the same sources in XCode 7 doesn't produce a crash. So please, don't suggest how to debug such kind of problem, how to set exception breakpoint etc.
EDIT
Since 9.1 release, it's no more reproducible.
As stated in comment to original question, there's no solution and no response on bug yet.
The openradar link: http://openradar.appspot.com/radar?id=6294934587965440
I'll be posting an updates here after the 9.1 release.
There are some empiric ways to come up with solution:
Override KVC setter setValue:forKey: and forbid empty string
key.
Use always the latest stable SDK to build.
But again, no actual response from Apple neither.
EDIT Since 9.1 release, it's no more reproducible.

Today Extension Crashes before launching on iOS 8.1.2

I've been making a today extension that downloads articles from a feed and display the latest ones.
The whole thing worked fine on iOS 8, still worked on iOS 8.1, then came iOS 8.1.2 and we started having complaints about the today extension not working anymore.
I tried debugging on iOS 8.1.2 devices, and before the extension even launch, it crashes with this error :
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: object cannot be nil (key: <__NSConcreteUUID 0x174027280> 5AFB07AB-5DCD-46FE-8D07-44DE0F3789F2)'
I have read this post about frequent bugs happening when developing a today extension : http://www.atomicbird.com/blog/ios-app-extension-tip
In his post, Tom Harrington says :
In iOS 8 (and other recent versions), enabling modules in Xcode's build settings means you don't need to explicitly list all the frameworks you want to use. They'll be found automatically.
But this isn't the case with NotificationCenter.framework, which Today extensions use. If you remove that from the build settings, you won't get any build warnings or errors. But when you try to load the extension, you'll get an exception from libextension.dylib and your extension won't load. The exception message is not enlightening:
2014-08-16 12:06:53.793 TodayTestExtension[41313:6111763] * Terminating
app due to uncaught exception 'NSInvalidArgumentException', reason: '*
setObjectForKey: object cannot be nil (key: <__NSConcreteUUID
0x7fd729422390> ED3B42F8-66CD-4CB0-BCD5-F3DBA6F34DB5)'
If you're doing a today extension, just leave that framework in the build settings. It shouldn't need to be there, but it does.
My extension does include NotificationCenter.framework in its build settings, but I suspect my problem might be similar in some way.
Anyone faced a similar problem? Any idea how to solve it?
This error also occurs if you use NSExtensionPrincipalClass inside "Info.plist" in order to define a base class (instead of using a storyboard) with the name of a ViewController which does not exist.
When using Swift, make sure to prefix the class with the module name (usually the name of the target) like "Module.MyViewController".
Eventually I tried to remove NotificationCenter.framework from my target and put it back, cleaned the project, and it's now working again. I guess the framework wasn't properly linked after all, though I could see it on my target with xcode. Also, I can't figure out why it did work, then stopped working with the arrival of 8.1.2.
I fixed this issue by adding the #objc attribute to the Swift class.
#objc(NotificationViewController)
class NotificationViewController: UIViewController, UNNotificationContentExtension {
...
}
Just experienced the same issue. For me, it was "Main Interface" property in "General settings" of the Keyboard target. It was blank, and i set it to my storyboard file and now it works like a charm.

Urban Airship crashes when calling takeoff

Upgrading to UrbanAirship 3.0.0 with Xcode 5.0, I'm getting an error when calling this code:
[UAirship takeOff:config];
The error is
+[NSJSONSerialization stringWithObject:]: unrecognized selector sent to class 0x3b2ca9fc
2013-09-19 15:02:31.981 [178:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSJSONSerialization stringWithObject:]: unrecognized selector sent to class 0x3b2ca9fc'
This doesn't seem to appear when setting the key "inProduction" to "YES" in the AirshipConfig.plist, which makes sense as calling takeOff: populates the instance of UAirShip.
It seems to be due to the category NSJSONSerialization+UAAdditions.
Any help on this one?
Thanks
To fix this issue, you must include "-ObjC" flag in "Other Linker Flags" found in your projects build settings.
UAirship library 3.x now makes use of Objective-C categories so this flag must be set to avoid the runtime exception.
Details on the issue can be found here:
https://developer.apple.com/library/mac/qa/qa1490/_index.html
Updated the docs:
http://docs.urbanairship.com/build/ios.html#build-settings
http://docs.urbanairship.com/topic_guides/ios_migration.html#linker-flags
Doesn't seam to be happening with the source: https://github.com/urbanairship/ios-library
You must have included both the libraries:
libUAirship-3.0.0.a
libUAirship-iOS5-3.0.0.a
You have to use either of the library for respective iOS
After looking at different solutions, it turns out that this fixes the issue:
• Download sources from https://github.com/urbanairship/ios-library directly into your App folder (don't take .zip given on their website)
• Drag & drop the Airship folder in your Project (do not use the AirshipLib one)
• Don't link any of the libUAirship-3.0.0.a or libUAirship-iOS5-3.0.0.a
• Boom. It's working.
Hope it'll help some others out there looking to fix this for ages.
Just to add, my problem was that I added -ObjC flag to the project, and it should be added to the target settings.
Also, if that does not compile, there is another option
-Wl,-force_load,<PathToYourLib>/libUAirship-4.0.0.a
Also should be added to the target. Fill the real path to your lib instead of <PathToYourLib>.

Getting an error from the Stanford iOS Class, but my code seems identical

I believe I did what the instructor did verbatim, but my app (it's a simple app) won't work and errors out if I press a button.
I click run, and it builds, but when I click a button in the iOS simulator the app crashes and brings me back to Xcode with an error.
I don't know what I did wrong. It brings me to the main.m file when we didn't even deal with that in the Stanford guide (maybe it has to do with the fact that the Stanford guide uses iOS 5.0 and I'm on 5.1?).
Here's the project if anyone wants to take a lot at it. I'm just really confused.
http://cl.ly/212A3q3J1m1F1y3A041A
(Also, did I just need to include the xcodeproject file, or was I right in including the whole project folder in a zip file?)
It looks like you have your buttons linked to a selector called digitedPressed:
They also appear to correctly be linked to digitPressed. Just remove the references to digitedPressed. (Right click the Calculator View Controller in your storyboard)
Don't forget to check the XCode debugger! This is the error the XCode debugger showed me:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CalculatorViewController digitedPressed:]: unrecognized selector sent to instance 0x9129cc0'

Resources