twitterparse-platformswift2xcode7-beta6

Twitter Login initialization via Parse not working: Swift


[Xcode V.7.0 Beta 6, OSX El Capitan, iOS9]

I'm trying to add the Twitter login using the latest version of the Parse SDK. I've tried several ways of integrating the Twitter Login with Parse but its not working. I've added my consumerkey/secret and it says that I need to initialize PFTwitterUtils which I have done.

You must call PFTwitterUtils initializeWithConsumerKey:consumerSecret: to use PFTwitterUtils" I posted the full error below as well as my github repository.

At the moment I didn't add the ParseTwitterUtils framework because it didn't say i needed to in the QuickStart guide on Parse.com. However, when I add the module I get a linker error. When i take it out, i get the error below.

Steps I took:

  1. At first, I was having an issue with the PFTwitterUtils module not appearing or being recognized. I built the project adding the frameworks in this link: https://www.parse.com/apps/quickstart?app_id=discounts--6#parse_data/mobile/ios/swift/existing and using the SDK here: https://www.parse.com/apps/quickstart?app_id=fblogin--81#parse_data/mobile/ios/swift/existing

(similar problem to this link: No such module 'Parse' following Parse iOS Swift Quickstart guide)

I posted the issue on github, thinking it's a bug on their end: https://github.com/ParsePlatform/Parse-SDK-iOS-OSX/issues/407

I was advised to check the Framework Search Path to see if the module lives inside the folder the search path is directing to. It looked good, but it still didn't work so I also tried adding another path to the ParseSDK and that also didn't work.

  1. I then took a Parse-Starter-project from another source where the PFTwitterUtils worked (my github repository is below with the new frameworks) but then I get the error I mentioned below. I'm assuming this is the better way of going about it because now the PFTwitterUtils is recognized within Xcode but not when building the project. I also checked the callback URL when making an app on twitter. I found a stack overflow question that had a problem with the callback URL. I edited that as well and it still doesn't work.

Here is the error I'm getting:

2015-10-14 13:13:18.374 ParseStarterProject[3757:390022] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'You must call PFTwitterUtils initializeWithConsumerKey:consumerSecret: to use PFTwitterUtils.' *** First throw call stack: ( 0 CoreFoundation 0x000000010f9849b5 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x0000000111927deb objc_exception_throw + 48 2 CoreFoundation 0x000000010f9848ed +[NSException raise:format:] + 205 3 ParseStarterProject 0x000000010eddcd7e +[PFTwitterUtils logInInBackground] + 31 4 ParseStarterProject 0x000000010eddce30 +[PFTwitterUtils logInWithBlock:] + 48 5 ParseStarterProject 0x000000010edca6b1 _TFC19ParseStarterProject14ViewController11viewDidLoadfS0_FT_T_ + 417 6 ParseStarterProject 0x000000010edca8c2 _TToFC19ParseStarterProject14ViewController11viewDidLoadfS0_FT_T_ + 34 7 UIKit 0x00000001106cbd05 -[UIViewController loadViewIfRequired] + 877 8 UIKit 0x00000001106cc054 -[UIViewController view] + 27 9 UIKit 0x00000001105ab77c -[UIWindow addRootViewControllerViewIfPossible] + 61 10 UIKit 0x00000001105abe79 -[UIWindow _setHidden:forced:] + 302 11 UIKit 0x00000001105bd6dc -[UIWindow makeKeyAndVisible] + 43 12 UIKit 0x000000011053dd13 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4003 13 UIKit 0x000000011054413d -[UIApplication _runWithMainScene:transitionContext:completion:] + 1755 14 UIKit 0x0000000110541390 -[UIApplication workspaceDidEndTransaction:] + 188 15 FrontBoardServices 0x00000001193b57ac -[FBSSerialQueue _performNext] + 192 16 FrontBoardServices 0x00000001193b5b1a -[FBSSerialQueue _performNextFromRunLoopSource] + 45 17 CoreFoundation 0x000000010f8b0b21 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 18 CoreFoundation 0x000000010f8a6a4c __CFRunLoopDoSources0 + 556 19 CoreFoundation 0x000000010f8a5f03 __CFRunLoopRun + 867 20 CoreFoundation 0x000000010f8a5918 CFRunLoopRunSpecific + 488 21 UIKit 0x0000000110540d2d -[UIApplication _run] + 402 22 UIKit 0x000000011054599e UIApplicationMain + 171 23 ParseStarterProject 0x000000010edcce6d main + 109 24 libdyld.dylib 0x0000000116bed92d start + 1 25 ??? 0x0000000000000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

//

In the repository the ParseTwitterUtils.framework module isn't there. But once I import it I get a linker error.

Could it be that i'm missing a Framework Search Path? When i add the Framework Search Path where the frameworks live, it doesn't change anything. Any ideas of how to add the TwitterSDK with Parse with the current SDKs I'm using?

Here's the link to my repository. https://github.com/rinyfo4/ParseStarterProject-2/tree/c512acb4360d45927f0cc5b34505d3caacae728c

Any help means a lot. Thank you in advance.

Please let me know if I can provide more information.


Solution

  • I solved it. As i mentioned, I went to github and was helped.

    This is the answer to what was going on:

    According to this guide, to enable authentication with Twitter - you need to call PFTwitterUtils.initializeWithConsumerKey:consumerSecret: The exception is being thrown about the fact that you simply didn't initialize the twitter utils, so there is no need to unlink/remove ParseTwitterUtils from Cocoapods. pod 'ParseTwitterUtils' and ParseTwitterUtils.framework are mutually exclusive, as they are absolutely the same thing, with the only difference on how you install them.

    Here is the solution: I needed to edit my AppDelegate didFinishLaunchingWithOptions method to reflect the following:

    `Parse.enableLocalDatastore()
    Parse.setApplicationId("...",
            clientKey: "...")
    
    PFTwitterUtils.initializeWithConsumerKey("...",     consumerSecret:"...")`
    

    Hope this helps whoever has this problem in the future.