TWTRTimelineViewController crashes: "initWithCoder: unrecognized selector sent to instance"


Based on the sample code provided here (Show Timelines), I have created a custom TWTRSearchViewController:


#import <TwitterKit/TwitterKit.h>
@interface TWTRSearchViewController : TWTRTimelineViewController


#import "TWTRSearchViewController.h"
@interface TWTRSearchViewController ()

@implementation TWTRSearchViewController
- (instancetype)init {
    TWTRAPIClient *APIClient = [[Twitter sharedInstance] APIClient];
    TWTRSearchTimelineDataSource *searchTimelineDataSource = [[TWTRSearchTimelineDataSource alloc] initWithSearchQuery:@"#twitterflock" APIClient:APIClient];
    return [super initWithDataSource:searchTimelineDataSource];

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

After the app starts, it crashes right away with the error message: -[TWTRSearchViewController initWithCoder:]: unrecognized selector sent to instance 0x7a88f1d0. The app crashes even before init or viewDidLoad is called.

What is wrong my code? Any idea on what I might have missed?



Are you setting up this app using Interface Builder?

Would you be willing to post a sample version of your app that exhibits this behavior?


Steven I am having the same problem as well, while using swift. I am also using storyboard to build my user interface. I followed the Twitter Kit SDK exactly and using this code:

import UIKit
import TwitterKit

class SearchTimelineViewController: TWTRTimelineViewController {
    convenience init() {
        let client = Twitter.sharedInstance().APIClient
        let dataSource = TWTRSearchTimelineDataSource(searchQuery: "#twitterflock", APIClient: client)
        self.init(dataSource: dataSource)
    override required init(dataSource: TWTRTimelineDataSource) {
        super.init(dataSource: dataSource)
    required init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")


Hi Steven,

yes, I set up my app using Interface Builder. You can find a sample of my app here: Dropbox

Please run the app and it will crash with the error message: [TwitterSearchViewController initWithCoder:]: unrecognized selector sent to instance xyz.

Everything has been set up as described in the Twitter API doc.

Thank you!



Alex, your linked app is missing the TwitterSearchViewController.h and .m files. Maybe you forgot to add them?

I would suggest a workaround of creating your view controllers in code for now until we create a sample for using Interface Builder.


I might have forgotten to add the files to the project. You find the missing files here: Dropbox

Please let me know if you are able to reproduce the error.

Could you provide a sample on how to create a view controller in code instead of using a Storyboard please?



I’m getting the same error with swift. View controller created with scoreboard, Xcode 6.3

I also had a problem with

required init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")

I get a compile error:

Cannot overwrite ‘init’ which has been marked unavailable

I commented out the routine so it would compile – don’t know if that effects things.

UPDATE: I tried the version here and it worked. But it is a fairly plain display – no headings, no way back to my calling VC, etc. So as a start I created a blank VC and did this…

        let vc = UIStoryboard(name: "Main", bundle:nil).instantiateViewControllerWithIdentifier("TwitterViewController") as! TwitterViewController
        self.presentViewController(vc, animated: true, completion: nil)

figuring I’d figure out how to pretty it up later. Well, it crashed the same way as the original one. So I guess you can only use this on a plain vanilla VC? Is there any way to customize things. As it is, it is not useful to me.

FURTHER UPDATE: The screen shot on the Timelines page shows a header with the handle and a back button. That is enough to work for me. How do I get that to display?

YET ANOTHER UPDATE; By using self.navigationController?.pushViewController instead of self.presentViewController I got my back button, Probably obvious to you all but I’m still learning the ins and outs of IOS :smile:


Hi @AlexR, @971nce, @FredWaltman1,

The initWithCoder: problem in Swift has been fixed in TwitterKit 1.6.1. Please check it out and let us know if that does not fix your problem.