2

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?

The Cubear Guy
  • 383
  • 4
  • 17

1 Answers1

13

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.

bl4ckr0se
  • 606
  • 8
  • 15
  • 1
    Yes, in objective C, `po [Twitter sharedInstance]` is an unrecognized object and gives an error, and I was wondering why, but `po [TWTRTwitter sharedInstance]` works. Your answer helped me to know to try TWTRTwitter – auspicious99 Sep 23 '19 at 09:59