19

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
  • I experienced the same thing. Gave up on swift and played in Obj-c instead. Maybe B2? Commented Jun 7, 2014 at 20:00

4 Answers 4

26

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.

Sign up to request clarification or add additional context in comments.

2 Comments

This is a very important answer. Lots of people having trouble using Swift to make widgets for iOS 8, and this quick-fix does the trick.
@n00neimp0rtant This is also covered here
3

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

See Apple's documentation

1 Comment

Thank you! This definitely solves my problem. Apparently Xcode doesn't include the appropriate 64-bit architecture automatically, as stated in the documentation. Everyting worked fine in the simulator, but on my device (5s) the widget's body wouldn't appear.
2

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

2 Comments

Are you sure, because I didn't find this in the release notes. So this means , I won't be able to work with extensions with Swift right now?
Im pretty sure its a bug, a lot of people have run into it, you will just have to wait for the next beta update, it is beta software after all!
2

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.

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.