iosswifttwittercocoapodstwitterkit

Twitter.sharedInstance() does not exist swift TwitterKit


I'm new to Xcode and swift.

I have started to work with TwitterKit, I have installed it on my project using cocoapods, I followed this tutorial: https://dev.twitter.com/twitterkit/ios/installation

The problem is, when I try to initialize TwitterKit in AppDelegate, I can't use the Twitter.sharedInstace, because Twitter does not exist. (I've imported the TwitterKit in the AppDelegate using import TwitterKit)

Here is my App Delegete class:

import UIKit
import TwitterKit
import Firebase
import FirebaseAuth

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        Twitter.sharedInstance().start(withConsumerKey:"********", consumerSecret:"*******") 
        //Here I get the error: Use of unresolved identifier 'Twitter'       
        return true
        }

What am I doing wrong?


Solution

  • If you use Swift 4 you need to use TWTRTwitter.sharedInstance() almost of Twitter.sharedInstance() because Twitter class has been replaced with TWTRTwitter. With Object C you haven't this problem beacause there is a macro that hidden this change. Unfortunately "dev.twitter.com" has not been updated.