Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TWTRLogInButton - NSURLErrorDomain error -1012

I am getting the following error:

error: The operation couldn’t be completed. (NSURLErrorDomain error -1012.)

This error appears in the console when I press the 'Log in with Twitter' button, which is created like so (exactly as it appears in the app):

    TWTRLogInButton* logInButton = [TWTRLogInButton buttonWithLogInCompletion:^(TWTRSession* session, NSError* error) {
        if (session) {

            NSLog(@"signed in as %@", [session userName]);


        } else {
            NSLog(@"error: %@", [error localizedDescription]);
        }
    }];

I don't see the NSLog for the error or 'signed in as %@'.

The error occurs when running the app on the iPhone 6S running iOS 9.1.

Fabric is up to date, version 1.12.0. However I have the following warnings:

Umbrella header for module 'TwitterKit' does not include header 'TWTRDefines.h'

Umbrella header for module 'TwitterKit' does not include header 'TWTRSession.h'

I am unsure if they are causing the problem - but skeptical as it runs on simulator and other devices.

In developer settings on the phone I have set 'Allow HTTP Services' to ON and in my.plist file I have set the key Allow Arbitrary Keys to YES as this appeared to solve the problem before.

Any advice would be appreciated as I am truly lost.

like image 615
Jack Nutkins Avatar asked Oct 30 '22 16:10

Jack Nutkins


2 Answers

There's an ongoing discussion of the -1012 error on the Twitter developer forum here:

https://twittercommunity.com/t/ios-twitter-kit-1-10-1-twtrloginbutton-responds-with-1012-error/52766

I downloaded this sample project posted by user michalhernas, which claims to replicate the issue: https://dl.dropboxusercontent.com/u/1824765/test-twitter.zip1

With the latest version of TwitterKit (1.13.1), the error message has changed to:

Error Domain=TwitterAPIErrorDomain Code=32 "Request failed: unauthorized (401)" UserInfo={NSErrorFailingURLKey=https://api.twitter.com/oauth/request_token, NSLocalizedDescription=Request failed: unauthorized (401), NSLocalizedFailureReason=Twitter API error : Could not authenticate you. (code 32)}

So, it's at least a different error. I would keep an eye on the Twitter thread. Funny enough I tried to post this there, but got an error when trying to authorize the forum app.

like image 115
cuomo456 Avatar answered Nov 15 '22 05:11

cuomo456


You might be able to solve the problem by completely removing TwitterKit libraries from XCode, delete the project from fabric.io and make a fresh installation of TwitterKit.

This is an issue in the TwitterKit and is already being investigated https://twittercommunity.com/t/xcode-7-twitterkit-warning/52390

Edit: And of course - what I always suggest - remove the derivedData, clean , clean build folder, restart XCode and remove & reinstall your app.

like image 45
MarkHim Avatar answered Nov 15 '22 06:11

MarkHim



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!