草庐IT

ios - Facebook SDK 登录在 swift 2 iOS 9 中抛出错误

coder 2023-07-15 原文

我尝试使用 iOS 9 和 Swift 2 中的 Facebook SDK 进行简单的 Facebook 登录,但它总是抛出一个错误:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSTaggedPointerString containsObject:]: unrecognized selector sent to instance 0xa326874756162667'

出现在usr/include/dispatch/once.h,我一个人解决不了。有人知道吗?

代码在这里:

import FBSDKCoreKit
import FBSDKLoginKit


let loginManager = FBSDKLoginManager()
loginManager.logInWithReadPermissions(["basic_info", "email", "user_likes"], fromViewController: self.parentViewController, handler: { (result, error) -> Void in
    if error != nil {
        print(FBSDKAccessToken.currentAccessToken())
    } else if result.isCancelled {
        print("Cancelled")
    } else {
        print("LoggedIn")
    }
})

更新:这是完整的错误堆栈:

2015-10-02 13:40:33.884 FacyNews[24902:1352812] -[NSTaggedPointerString containsObject:]: unrecognized selector sent to instance 0xa326874756162667
2015-10-02 13:40:33.889 FacyNews[24902:1352812] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSTaggedPointerString containsObject:]: unrecognized selector sent to instance 0xa326874756162667'
*** First throw call stack:
(
	0   CoreFoundation                      0x000000010dbe8f65 __exceptionPreprocess + 165
	1   libobjc.A.dylib                     0x000000010f87adeb objc_exception_throw + 48
	2   CoreFoundation                      0x000000010dbf158d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
	3   CoreFoundation                      0x000000010db3ef7a ___forwarding___ + 970
	4   CoreFoundation                      0x000000010db3eb28 _CF_forwarding_prep_0 + 120
	5   FBSDKCoreKit                        0x000000010d52ea8b +[FBSDKInternalUtility isRegisteredCanOpenURLScheme:] + 171
	6   FBSDKCoreKit                        0x000000010d52e8da +[FBSDKInternalUtility checkRegisteredCanOpenURLScheme:] + 362
	7   FBSDKCoreKit                        0x000000010d52d0ed __46+[FBSDKInternalUtility isFacebookAppInstalled]_block_invoke + 45
	8   libdispatch.dylib                   0x0000000110ded49b _dispatch_client_callout + 8
	9   libdispatch.dylib                   0x0000000110dd8e28 dispatch_once_f + 543
	10  FBSDKCoreKit                        0x000000010d52cff7 +[FBSDKInternalUtility isFacebookAppInstalled] + 87
	11  FBSDKLoginKit                       0x000000010d6d6cb1 -[FBSDKLoginManager logInParametersWithPermissions:] + 449
	12  FBSDKLoginKit                       0x000000010d6d7358 -[FBSDKLoginManager logInWithBehavior:] + 88
	13  FBSDKLoginKit                       0x000000010d6d72d4 -[FBSDKLoginManager logInWithPermissions:handler:] + 292
	14  FBSDKLoginKit                       0x000000010d6d55e7 -[FBSDKLoginManager logInWithReadPermissions:fromViewController:handler:] + 343
	15  FacyNews                            0x000000010d3a2e5c _TFFC8FacyNews20MasterViewController14viewWillAppearFS0_FSbT_U_FCSo13UIAlertActionT_ + 700
	16  FacyNews                            0x000000010d3a3297 _TTRXFo_oCSo13UIAlertAction_dT__XFo_iS__iT__ + 23
	17  FacyNews                            0x000000010d39e131 _TPA__TTRXFo_oCSo13UIAlertAction_dT__XFo_iS__iT__ + 81
	18  FacyNews                            0x000000010d3a2b40 _TTRXFo_iCSo13UIAlertAction_iT__XFo_oS__dT__ + 32
	19  FacyNews                            0x000000010d3a2b8c _TTRXFo_oCSo13UIAlertAction_dT__XFdCb_dS__dT__ + 60
	20  UIKit                               0x000000010e709fa5 -[UIAlertController _fireOffActionOnTargetIfValidForAction:] + 96
	21  UIKit                               0x000000010e70a785 __85-[UIAlertController _dismissAnimated:triggeringAction:triggeredByPopoverDimmingView:]_block_invoke + 30
	22  UIKit                               0x000000010e55fc9f -[UIPresentationController transitionDidFinish:] + 1248
	23  UIKit                               0x000000010e563210 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_2 + 183
	24  UIKit                               0x000000010edb31e9 -[_UIViewControllerTransitionContext completeTransition:] + 101
	25  UIKit                               0x000000010e4a9daa -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 644
	26  UIKit                               0x000000010e4883a7 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 241
	27  UIKit                               0x000000010e488756 -[UIViewAnimationState animationDidStop:finished:] + 80
	28  QuartzCore                          0x00000001135e8d70 _ZN2CA5Layer23run_animation_callbacksEPv + 308
	29  libdispatch.dylib                   0x0000000110ded49b _dispatch_client_callout + 8
	30  libdispatch.dylib                   0x0000000110dd534b _dispatch_main_queue_callback_4CF + 1738
	31  CoreFoundation                      0x000000010db493e9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
	32  CoreFoundation                      0x000000010db0a939 __CFRunLoopRun + 2073
	33  CoreFoundation                      0x000000010db09e98 CFRunLoopRunSpecific + 488
	34  GraphicsServices                    0x00000001130a2ad2 GSEventRunModal + 161
	35  UIKit                               0x000000010e403676 UIApplicationMain + 171
	36  FacyNews                            0x000000010d39959d main + 109
	37  libdyld.dylib                       0x0000000110e2192d start + 1
	38  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

提前致谢。

最佳答案

我已经解决了这个问题。由于文档中没有关于 LSApplicationQueriesSchemes 的任何内容,但我收到一条关于缺少它的错误消息,我将 key 和“fbauth2”值作为字符串写入 info.plist,但它是一个数组,SDK 尝试获取不检查字符串数组的元素是否为数组。

但是,感谢您的帮助回答。

关于ios - Facebook SDK 登录在 swift 2 iOS 9 中抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32906178/

有关ios - Facebook SDK 登录在 swift 2 iOS 9 中抛出错误的更多相关文章

  1. ruby - 如何验证 IO.copy_stream 是否成功 - 2

    这里有一个很好的答案解释了如何在Ruby中下载文件而不将其加载到内存中:https://stackoverflow.com/a/29743394/4852737require'open-uri'download=open('http://example.com/image.png')IO.copy_stream(download,'~/image.png')我如何验证下载文件的IO.copy_stream调用是否真的成功——这意味着下载的文件与我打算下载的文件完全相同,而不是下载一半的损坏文件?documentation说IO.copy_stream返回它复制的字节数,但是当我还没有下

  2. Ruby 文件 IO 定界符? - 2

    我正在尝试解析一个文本文件,该文件每行包含可变数量的单词和数字,如下所示:foo4.500bar3.001.33foobar如何读取由空格而不是换行符分隔的文件?有什么方法可以设置File("file.txt").foreach方法以使用空格而不是换行符作为分隔符? 最佳答案 接受的答案将slurp文件,这可能是大文本文件的问题。更好的解决方案是IO.foreach.它是惯用的,将按字符流式传输文件:File.foreach(filename,""){|string|putsstring}包含“thisisanexample”结果的

  3. Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting - 2

    1.错误信息:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:requestcanceledwhilewaitingforconnection(Client.Timeoutexceededwhileawaitingheaders)或者:Errorresponsefromdaemon:Gethttps://registry-1.docker.io/v2/:net/http:TLShandshaketimeout2.报错原因:docker使用的镜像网址默认为国外,下载容易超时,需要修改成国内镜像地址(首先阿里

  4. ruby - 为什么不能使用类IO的实例方法noecho? - 2

    print"Enteryourpassword:"pass=STDIN.noecho(&:gets)puts"Yourpasswordis#{pass}!"输出:Enteryourpassword:input.rb:2:in`':undefinedmethod`noecho'for#>(NoMethodError) 最佳答案 一开始require'io/console'后来的Ruby1.9.3 关于ruby-为什么不能使用类IO的实例方法noecho?,我们在StackOverflow上

  5. ruby - 使用 Ruby 和 Mechanize 登录网站 - 2

    我需要从站点抓取数据,但它需要我先登录。我一直在使用hpricot成功地抓取其他网站,但我是使用mechanize的新手,我真的对如何使用它感到困惑。我看到这个例子经常被引用:require'rubygems'require'mechanize'a=Mechanize.newa.get('http://rubyforge.org/')do|page|#Clicktheloginlinklogin_page=a.click(page.link_with(:text=>/LogIn/))#Submittheloginformmy_page=login_page.form_with(:act

  6. ruby-on-rails - 使用用户或管理员模型和 Basecamp 样式子域设计登录 - 2

    我为Devise用户和管理员提供了不同的模型。我也在使用Basecamp风格的子域。除了我需要能够以用户或管理员身份进行身份验证的一些Controller和操作外,一切都运行良好。目前我有authenticate_user!在我的application_controller.rb中设置,对于那些只有管理员才能访问的Controller和操作,我使用skip_before_filter跳过它。不幸的是,我不能简单地指定每个Controller的身份验证要求,因为我仍然需要一些Controller和操作才能被用户或管理员访问。我尝试了一些方法都无济于事。看来,如果我移动authentica

  7. ruby - 如何使用 omniauth/oauth 对每秒登录数进行基准测试? ( ruby +rspec) - 2

    我想用一个(自己的)omniauth提供商来衡量每秒可以登录多少次。我需要了解此omniauth/oauth请求的性能如何,以及此身份验证是否具有可扩展性?到目前为止我得到了什么:defperformance_auth(user_count=10)bm=Benchmark.realtimedouser_count.timesdo|n|forkdoclick_on'Logout'omniauth_config_mock(:provider=>"foo",:uid=>n,:email=>"foo#{n}@example.net")visit"/account/auth/foo/"enden

  8. ruby - 为 IO::popen 拯救 "command not found" - 2

    当我将IO::popen与不存在的命令一起使用时,我在屏幕上打印了一条错误消息:irb>IO.popen"fakefake"#=>#irb>(irb):1:commandnotfound:fakefake有什么方法可以捕获此错误,以便我可以在脚本中进行检查? 最佳答案 是:升级到ruby​​1.9。如果您在1.9中运行它,则会引发Errno::ENOENT,您将能够拯救它。(编辑)这是在1.8中的一种hackish方式:error=IO.pipe$stderr.reopenerror[1]pipe=IO.popen'qwe'#

  9. ruby - IO::EAGAINWaitReadable:资源暂时不可用 - 读取会阻塞 - 2

    当我尝试使用“套接字”库中的方法“read_nonblock”时出现以下错误IO::EAGAINWaitReadable:Resourcetemporarilyunavailable-readwouldblock但是当我通过终端上的IRB尝试时它工作正常如何让它读取缓冲区? 最佳答案 IgetthefollowingerrorwhenItrytousethemethod"read_nonblock"fromthe"socket"library当缓冲区中的数据未准备好时,这是预期的行为。由于异常IO::EAGAINWaitReadab

  10. ruby - 如何使用 Ruby 和 eventmachine 登录? - 2

    我正在使用Ruby和Eventmachine库编写一个应用程序。我真的很喜欢非阻塞I/O和事件驱动系统的想法,我遇到的问题是日志记录。我正在使用Ruby的标准记录器库。并不是说日志记录需要永远,但它似乎不应该阻塞,但它确实阻塞了。是否有某个库将Ruby的标准记录器实现扩展为非阻塞的,或者我应该只调用EM::defer进行日志记录调用?有没有办法让eventmachine已经为我做这件事? 最佳答案 我最终将记录器包装在一个启动线程并具有FIFO队列的单例类中。日志记录会将日志信息转储到队列中,线程只是循环,从队列中拉出内容并使用真正

随机推荐