iOS 8 Beta Today extension widget not showing in a Swift app?

流过昼夜 提交于 2019-11-27 17:24:43

问题


Today extension doesn't show up in a Swift app, but it does in a Objective C app.

What I did was to add a UILabel with some content on the storyboard for the swift and objective c apps.

It showed up when I ran the Objective C app, but not when I executed the Swift app.

Am I missing something here?


回答1:


You can comment out the supplied init method.

//    init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
//        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
//        // Custom initialization
//    }

This will allow your extension to run properly. The issue seems to be caused by differing initializer behavior between Swift and Objective-C. Removing the above initializer will inherit all of the required initializers from the superclass.

Found that solution on the apple developer forums for your reference.

Note: You may have to Clean and Build your project after doing this before the changes will have any effect

The extension is actually crashing, with an error like:

fatal error: use of unimplemented initializer 'init(coder:)' for class 'com_blabla_blabla_MyTodayExtension.TodayViewController'

This indicates that another option would be to implement:

init(coder aDecoder: NSCoder!) {
    super.init(coder: aDecoder)
    // Custom initialization here
}

if you want to retain the ability to do custom initialization.




回答2:


An app extension target must include the arm64 (iOS) or x86_64 architecture (OS X) in its Architectures build settings.

See Apple's documentation




回答3:


Xcode6 is beta and this is a bug with it, you will have to wait for a new release.




回答4:


The problem for me was that the extension's deployment target was set to a different version than my app's target. You should confirm the extension's target is set appropriately because it may target a different version.



来源:https://stackoverflow.com/questions/24074691/ios-8-beta-today-extension-widget-not-showing-in-a-swift-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!