iosobjective-cios8-today-widgettoday-extension

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?


Solution

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