Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 999
Marc_V Avatar asked Jan 26 '15 15:01

Marc_V


1 Answers

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".

like image 180
WMD Avatar answered Oct 03 '22 05:10

WMD