OS X Today Widget: Use storyboard?

Is it possible to use storyboard instead of xib when writing a OS X Today View Widget? The default XCode template uses xib. I've searched for an example on using a storyboard instead but could not find anything. What I have tried is to change NSExtension in info from NSExtensionPrincipalClass to NSExtensionMainStoryboard, setup a storyboard with a TodayViewController Widget as initial controller etc. If I try to run the widget simulator I get the following error: "Failed to load extension view controller". So apparently I'm missing something trivial or maybe it is not possible?

Answered by bob133 in 94224022

Hmm. Yes, that totally contradicts the document I found. The bit about being an "immediate child" just means it has to be directly under the NSExtension item. It doesn't have to be in [0], but it can't be in any sub-items or in any other branch of the property list. Judging by the revision dates, the one you found has a more recent date, so it's more likely to be correct than the one I found. Maybe fiddle with it and see if you can get it to work. (Don't forget that there may be an issue with the storyboard that keeps it from loading—stuff like this isn't always a configuration issue.)


You should file a bug report to alert someone about the contradiction. Here's the link: bugreport.apple.com

Could you post the complete error message, including any stack traces?

Nothing interesting in the logs when I run the widget simulator:

10/12/15 03:51:17,778 pkd[305]: INSTALLED:com.mXXX.XXX com.mXXX.XXX(1.0) <__NSConcreteUUID 0x7fb819e45220> 2CA65A24-39B8-4973-B7C6-356C25409665 /Users/hauk/Library/Developer/Xcode/DerivedData/XXX-egqjhiuwpdeapxehfyijzaozdyqj/Build/Products/Debug/XXX.app/Contents/PlugIns/XXX Today.appex
10/12/15 03:51:18,899 pkd[305]: UNINSTALLED:com.mXXX.XXX com.mXXX.XXX(1.0) 2CA65A24-39B8-4973-B7C6-356C25409665 /Users/hauk/Library/Developer/Xcode/DerivedData/XXX-egqjhiuwpdeapxehfyijzaozdyqj/Build/Products/Debug/XXX.app/Contents/PlugIns/XXX Today.appex
10/12/15 03:51:18,909 pkd[305]: INSTALLED:com.mXXX.XXX com.mXXX.XXX(1.0) <__NSConcreteUUID 0x7fb81b34d620> 53C56C48-0483-4F41-B653-408E26ACFFE3 /Users/hauk/Library/Developer/Xcode/DerivedData/XXX-egqjhiuwpdeapxehfyijzaozdyqj/Build/Products/Debug/XXX.app/Contents/PlugIns/XXX Today.appex
10/12/15 03:51:19,716 pkd[305]: enabling pid=7793 for plug-in com.mXXX.XXX(1.0) 53C56C48-0483-4F41-B653-408E26ACFFE3 /Users/hauk/Library/Developer/Xcode/DerivedData/XXX-egqjhiuwpdeapxehfyijzaozdyqj/Build/Products/Debug/XXX.app/Contents/PlugIns/XXX Today.appex
10/12/15 03:51:19,761 taskgated-helper[7595]: validated embedded provisioning profile: file:///Users/hauk/Library/Developer/Xcode/DerivedData/XXX-egqjhiuwpdeapxehfyijzaozdyqj/Build/Products/Debug/XXX.app/Contents/PlugIns/XXX%20Today.appex/Contents/embedded.provisionprofile

In the XCode console the only thing I have is; 2015-12-10 03:28:17.031 XXX Today[6972:2333627] Failed to load extension view controller.


I can see the compiled Today.storyboardc file in Contents/Resources and info contains the entry NSExtension[0]:NSExtensionMainStoryboard:Today. So on OS X this is apparently not enough to load the storyboard and something is amiss.

I just took a look at the App Extension Programming Guide, and it says that the NSExtensionMainStoryboard info key is supported on iOS only. So you'll have to use a nib at least for the basic interface on OS X. However, you could always define a custom storyboard and use a bit of glue code to embed that in your root view controller.

Thanks for taking the time to investigate. However, I found doc that says the opposite. Maybe the problem is as trivial as it says in the doc: "This key, if used, must be placed as an immediate child of the NSExtension key". That is, the key must be in position [0] in the NSExtension array while I had it in postion [2]. I didn't know any more "glue" was needed, but I would much appreciate any pointers if I'm wrong.

Accepted Answer

Hmm. Yes, that totally contradicts the document I found. The bit about being an "immediate child" just means it has to be directly under the NSExtension item. It doesn't have to be in [0], but it can't be in any sub-items or in any other branch of the property list. Judging by the revision dates, the one you found has a more recent date, so it's more likely to be correct than the one I found. Maybe fiddle with it and see if you can get it to work. (Don't forget that there may be an issue with the storyboard that keeps it from loading—stuff like this isn't always a configuration issue.)


You should file a bug report to alert someone about the contradiction. Here's the link: bugreport.apple.com

OS X Today Widget: Use storyboard?
 
 
Q