Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 420
The Cubear Guy Avatar asked Dec 06 '25 14:12

The Cubear Guy


1 Answers

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.

like image 120
bl4ckr0se Avatar answered Dec 08 '25 05:12

bl4ckr0se



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!