TWTRLogInButton - NSURLErrorDomain 错误 -1012

TWTRLogInButton - NSURLErrorDomain error -1012

我收到以下错误:

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

当我按下 'Log in with Twitter' 按钮时,此错误出现在控制台中,它是这样创建的(与它在应用程序中显示的完全一样):

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

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


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

我没有看到错误或 'signed in as %@' 的 NSLog。

当运行应用在iPhone6S运行iOS9.1.

时出现错误

结构是最新的,版本 1.12.0。但是我有以下警告:

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

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

我不确定是否是它们导致了问题 - 但持怀疑态度,因为它在模拟器和其他设备上运行。

在 phone 的开发者设置中,我将 'Allow HTTP Services' 设置为 ON,在 my.plist 文件中,我将允许任意键设置为 YES,因为这似乎可以解决问题之前。

任何建议将不胜感激,因为我真的迷路了。

您可以通过从 XCode 中完全删除 TwitterKit 库,从 fabric.io 中删除项目并重新安装 TwitterKit 来解决问题。

这是 TwitterKit 中的一个问题,已经在调查中https://twittercommunity.com/t/xcode-7-twitterkit-warning/52390

编辑:当然 - 我一直建议 - 删除 derivedData,清理,清理构建文件夹,重新启动 XCode 并删除并重新安装你的应用程序。

这可能是应用程序传输安全问题。

您可以将域列入白名单以使其不受此安全保护或完全禁用。以下 link 概述了处理和解决此问题的方法。

http://www.neglectedpotential.com/2015/06/working-with-apples-application-transport-security/

希望对您有所帮助。

这里的 Twitter 开发者论坛上正在讨论 -1012 错误:

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

我下载了这个由用户 michalhernas 编辑的示例项目 post,它声称重现了这个问题:https://dl.dropboxusercontent.com/u/1824765/test-twitter.zip1

使用最新版本的 TwitterKit (1.13.1),错误消息已更改为:

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)}

所以,这至少是一个不同的错误。我会密切关注 Twitter 线程。有趣的是,我尝试在那里 post 这个,但是在尝试授权论坛应用程序时出现错误。