Search code examples
iostwitterswift2xcode7

iOS Swift 2 Twitter Login integration


I am trying to integrate Twitter login in my project. I am using Xcode7 and following Twitter login tutorial. But I am getting the error in AppDelegate value of type 'Twitter' has no member start. I have installed pod 'TwitterKit' and added #import <TwitterKit/TwitterKit.h> in bridging header. Below is the code in AppDelegate

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Twitter.sharedInstance().start(withConsumerKey:"hTpkPVU4pThkM0", consumerSecret:"ovEqziMzLpUOF163Qg2mj")

return true
}

any help would be appreciated. Thanks in advance


Solution

  • From your code it seems like you are using Swift2 but you are using Swift3 method for Twitterkit

    Use this Swift2 method and try again, It should work for you

    Twitter.sharedInstance().startWithConsumerKey("your_key", consumerSecret: "your_secret")