就像在iOS 9上一样,我必须对info.plist文件进行一些小的更改才能启用跨应用程序打开:<key>LSApplicationQueriesSchemes</key><array> <string>fbauth</string></array>,并且由于在iOS9上更改了UIAppDelegate中的openURL方法,因此我更改了Facebook为此提供的openURL代码段:func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool { return FBSDKApplicationDelegate.sharedInstance().application( application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)}对此:func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool{ return FBSDKApplicationDelegate.sharedInstance().application( app, openURL: url, sourceApplication: options["UIApplicationOpenURLOptionsSourceApplicationKey"] as? String, annotation: nil)} 问题与解答;问题所以我的问题是,即使一切运行正常(我的意思是整个登录按钮过程加上从Facebook图形中获取用户数据),当我从模拟器或直接从XCode在iPhone上运行应用程序时,我执行在我的应用程序上运行相同的过程时遇到问题,但这一次是从存档中安装的.我曾经尝试过使用OTA应用程序或使用存档的IPA文件在Xcode组织者中安装的应用程序.在这两种情况下, Facebook返回我的应用程序时都会崩溃.由于我无法使用Xcode的调试器,所以我只有崩溃日志.Incident Identifier: 842E980C-8DE0-485F-8B3E-8CD889D34B3BCrashReporter Key: 3e77866746471e437b9174c6082fc9136a18514fHardware Model: iPhone7,2Process: Process Name [1086]Path: /private/var/mobile/Containers/Bundle/Application/AA43C098-DFC0-483C-A073-C2401078E9FC/Some App.app/someappIdentifier: fr.someapp.Some-AppVersion: 1 (1.0)Code Type: ARM-64 (Native)Parent Process: launchd [1]Date/Time: 2015-07-19 20:18:41.41 +0200Launch Time: 2015-07-19 20:18:35.35 +0200OS Version: iOS 9.0 (13A4293g)Report Version: 105Exception Type: EXC_BREAKPOINT (SIGTRAP)Exception Codes: 0x0000000000000001, 0x000000010005f6e4Triggered by Thread: 0Filtered syslog:None foundGlobal Trace Buffer (reverse chronological seconds):0.228132 AppleJPEG 0x000000018dba5008 [0x13e871e00] Decoding completed without errors0.250546 AppleJPEG 0x000000018dba31a0 [0x13e871e00] Options: 1080x1920 [FFFFFFFF,FFFFFFFF] 000250600.250629 AppleJPEG 0x000000018dba3058 [0x13e871e00] Decoding: C0 0x04380780 0x0044304A 0x22111100 0x00000000 1755920.256474 AppleJPEG 0x000000018dba5008 [0x13e867200] Decoding completed without errors0.261051 AppleJPEG 0x000000018dba31a0 [0x13e867200] Options: 750x1334 [FFFFFFFF,FFFFFFFF] 000250600.261101 AppleJPEG 0x000000018dba3058 [0x13e867200] Decoding: C0 0x02EE0536 0x002F304A 0x22111100 0x00000000 758820.262141 AppleJPEG 0x000000018dba5008 [0x13e85c600] Decoding completed without errors0.272075 AppleJPEG 0x000000018dba31a0 [0x13e85c600] Options: 750x1334 [FFFFFFFF,FFFFFFFF] 000250600.272281 AppleJPEG 0x000000018dba3058 [0x13e85c600] Decoding: C0 0x02EE0536 0x002F304A 0x22111100 0x00000000 1088260.273070 AppleJPEG 0x000000018dba5008 [0x13f04bc00] Decoding completed without errors0.283798 AppleJPEG 0x000000018dba31a0 [0x13f04bc00] Options: 750x1334 [FFFFFFFF,FFFFFFFF] 000250600.283798 AppleJPEG 0x000000018dba3058 [0x13f04bc00] Decoding: C0 0x02EE0536 0x002F304A 0x22111100 0x00000000 729675.783070 CFNetwork 0x0000000186041d44 TCP Conn 0x13e5a1b90 SSL Handshake DONE5.874750 CFNetwork 0x0000000186041c54 TCP Conn 0x13e5a1b90 starting SSL negotiation5.875481 CFNetwork 0x00000001860e0e14 TCP Conn 0x13e5a1b90 complete. fd: 6, err: 05.876954 CFNetwork 0x00000001860e21e4 TCP Conn 0x13e5a1b90 event 1. err: 05.984181 CFNetwork 0x00000001860e22f8 TCP Conn 0x13e5a1b90 started5.992333 CFNetwork 0x0000000186137140 Creating default cookie storage with default identifier5.992333 CFNetwork 0x000000018613710c Faulting in CFHTTPCookieStorage singleton5.992562 CFNetwork 0x0000000186188068 Faulting in NSHTTPCookieStorage singleton6.189612 AppleJPEG 0x000000018dba234c [0x13e871e00] Created session6.190797 AppleJPEG 0x000000018dba234c [0x13e867200] Created session6.192109 AppleJPEG 0x000000018dba234c [0x13e85c600] Created session6.197484 AppleJPEG 0x000000018dba234c [0x13f04bc00] Created sessionThread 0 name: Dispatch queue: com.apple.main-threadThread 0 Crashed:0 Some app 0x000000010005f6e4 function signature specialization <Arg[0] = Owned To Guaranteed, Arg[1] = Owned To Guaranteed, Arg[2] = Owned To Guaranteed and Exploded, Arg[3] = Dead> of Some_App.AppDelegate.application (Some_App.AppDelegate)(ObjectiveC.UIApplication, openURL : ObjectiveC.NSURL, options : [Swift.String : Swift.AnyObject]) -> Swift.Bool (AppDelegate.swift:100)1 Some_app 0x000000010005e7a8 @objc Some_App.AppDelegate.application (Some_app.AppDelegate)(ObjectiveC.UIApplication, openURL : ObjectiveC.NSURL, options : [Swift.String : Swift.AnyObject]) -> Swift.Bool (AppDelegate.swift:0)2 UIKit 0x000000018c1ee664 0x18bf34000 + 28606443 UIKit 0x000000018c1ee168 0x18bf34000 + 28593684 UIKit 0x000000018c1f5c30 0x18bf34000 + 28908005 UIKit 0x000000018c1fb644 0x18bf34000 + 29138606 UIKit 0x000000018c1fa9dc 0x18bf34000 + 29106847 UIKit 0x000000018c1e6fd4 0x18bf34000 + 28302928 UIKit 0x000000018c1e6eb4 0x18bf34000 + 28300049 FrontBoardServices 0x00000001905ffbe0 0x1905d8000 + 16278410 FrontBoardServices 0x00000001905fff60 0x1905d8000 + 16368011 CoreFoundation 0x00000001868eb8b4 0x18680c000 + 91563612 CoreFoundation 0x00000001868eb348 0x18680c000 + 91424813 CoreFoundation 0x00000001868e901c 0x18680c000 + 90524414 CoreFoundation 0x00000001868157fc 0x18680c000 + 3890815 GraphicsServices 0x00000001918a316c 0x191898000 + 4542016 UIKit 0x000000018bfae5e4 0x18bf34000 + 50122017 Some app 0x000000010005eaa4 main (AppDelegate.swift:14)18 libdyld.dylib 0x000000019bb128b4 0x19bb10000 + 10420似乎当Facebook回调我的应用程序时,崩溃发生在我的AppDelegate的openURL方法中.如上所述,从iOS9开始,有两种方法可以对这种方法进行编码,我尝试了两种方法.如果删除方法中的Facebook代码,则不会崩溃,但无法登录.因此,崩溃的线是Facebook的线.而且仅当我的应用程序是从存档中安装时它才崩溃.有任何想法吗?也许Facebook的SDK在此特定情况下存在错误?解决方案 我找到了答案看起来像是发布模式问题.通过启用Xcode来运行Release版本,我可以调试我的问题.这是由参数sourceApplication引起的,在释放模式下,显然需要将其设为unwrapped.不知道为什么,但是至少我知道了.func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool{ return FBSDKApplicationDelegate.sharedInstance().application( app, openURL: url, sourceApplication: options["UIApplicationOpenURLOptionsSourceApplicationKey"] as! String, annotation: nil)}ContextI am using the FBSDKLoginButton with my app. I am on Xcode 7.0 and my iPhone is running iOS 9 beta 3. I followed every step showed by Facebook (creating the app, etc) and followed the steps for adding the button as in https://developers.facebook.com/docs/facebook-login/ios#login-button.As I am on iOS 9, I had to add some minor changes to the info.plist file to enable cross-app opening: <key>LSApplicationQueriesSchemes</key><array> <string>fbauth</string></array>and since the openURL method from UIAppDelegate changed on iOS9,I changed the openURL code snippet Facebook provides from this:func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool { return FBSDKApplicationDelegate.sharedInstance().application( application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)}to this:func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool{ return FBSDKApplicationDelegate.sharedInstance().application( app, openURL: url, sourceApplication: options["UIApplicationOpenURLOptionsSourceApplicationKey"] as? String, annotation: nil)}Issue & QuestionSo my issue here is that even though everything works perfectly (I mean the whole login button process plus getting user data from the Facebook graph) when I run the app from the simulator or directly on my iPhone from XCode, I do have a problem when I run the same process with my application but this time installed from an archive. I have tried either from an OTA app or an app installed with the Xcode organizer using the archive's IPA file. In both case I get a crash when Facebook returns back to my app. Since I cannot be using Xcode's debugger all I have is a crash log.Incident Identifier: 842E980C-8DE0-485F-8B3E-8CD889D34B3BCrashReporter Key: 3e77866746471e437b9174c6082fc9136a18514fHardware Model: iPhone7,2Process: Process Name [1086]Path: /private/var/mobile/Containers/Bundle/Application/AA43C098-DFC0-483C-A073-C2401078E9FC/Some App.app/someappIdentifier: fr.someapp.Some-AppVersion: 1 (1.0)Code Type: ARM-64 (Native)Parent Process: launchd [1]Date/Time: 2015-07-19 20:18:41.41 +0200Launch Time: 2015-07-19 20:18:35.35 +0200OS Version: iOS 9.0 (13A4293g)Report Version: 105Exception Type: EXC_BREAKPOINT (SIGTRAP)Exception Codes: 0x0000000000000001, 0x000000010005f6e4Triggered by Thread: 0Filtered syslog:None foundGlobal Trace Buffer (reverse chronological seconds):0.228132 AppleJPEG 0x000000018dba5008 [0x13e871e00] Decoding completed without errors0.250546 AppleJPEG 0x000000018dba31a0 [0x13e871e00] Options: 1080x1920 [FFFFFFFF,FFFFFFFF] 000250600.250629 AppleJPEG 0x000000018dba3058 [0x13e871e00] Decoding: C0 0x04380780 0x0044304A 0x22111100 0x00000000 1755920.256474 AppleJPEG 0x000000018dba5008 [0x13e867200] Decoding completed without errors0.261051 AppleJPEG 0x000000018dba31a0 [0x13e867200] Options: 750x1334 [FFFFFFFF,FFFFFFFF] 000250600.261101 AppleJPEG 0x000000018dba3058 [0x13e867200] Decoding: C0 0x02EE0536 0x002F304A 0x22111100 0x00000000 758820.262141 AppleJPEG 0x000000018dba5008 [0x13e85c600] Decoding completed without errors0.272075 AppleJPEG 0x000000018dba31a0 [0x13e85c600] Options: 750x1334 [FFFFFFFF,FFFFFFFF] 000250600.272281 AppleJPEG 0x000000018dba3058 [0x13e85c600] Decoding: C0 0x02EE0536 0x002F304A 0x22111100 0x00000000 1088260.273070 AppleJPEG 0x000000018dba5008 [0x13f04bc00] Decoding completed without errors0.283798 AppleJPEG 0x000000018dba31a0 [0x13f04bc00] Options: 750x1334 [FFFFFFFF,FFFFFFFF] 000250600.283798 AppleJPEG 0x000000018dba3058 [0x13f04bc00] Decoding: C0 0x02EE0536 0x002F304A 0x22111100 0x00000000 729675.783070 CFNetwork 0x0000000186041d44 TCP Conn 0x13e5a1b90 SSL Handshake DONE5.874750 CFNetwork 0x0000000186041c54 TCP Conn 0x13e5a1b90 starting SSL negotiation5.875481 CFNetwork 0x00000001860e0e14 TCP Conn 0x13e5a1b90 complete. fd: 6, err: 05.876954 CFNetwork 0x00000001860e21e4 TCP Conn 0x13e5a1b90 event 1. err: 05.984181 CFNetwork 0x00000001860e22f8 TCP Conn 0x13e5a1b90 started5.992333 CFNetwork 0x0000000186137140 Creating default cookie storage with default identifier5.992333 CFNetwork 0x000000018613710c Faulting in CFHTTPCookieStorage singleton5.992562 CFNetwork 0x0000000186188068 Faulting in NSHTTPCookieStorage singleton6.189612 AppleJPEG 0x000000018dba234c [0x13e871e00] Created session6.190797 AppleJPEG 0x000000018dba234c [0x13e867200] Created session6.192109 AppleJPEG 0x000000018dba234c [0x13e85c600] Created session6.197484 AppleJPEG 0x000000018dba234c [0x13f04bc00] Created sessionThread 0 name: Dispatch queue: com.apple.main-threadThread 0 Crashed:0 Some app 0x000000010005f6e4 function signature specialization <Arg[0] = Owned To Guaranteed, Arg[1] = Owned To Guaranteed, Arg[2] = Owned To Guaranteed and Exploded, Arg[3] = Dead> of Some_App.AppDelegate.application (Some_App.AppDelegate)(ObjectiveC.UIApplication, openURL : ObjectiveC.NSURL, options : [Swift.String : Swift.AnyObject]) -> Swift.Bool (AppDelegate.swift:100)1 Some_app 0x000000010005e7a8 @objc Some_App.AppDelegate.application (Some_app.AppDelegate)(ObjectiveC.UIApplication, openURL : ObjectiveC.NSURL, options : [Swift.String : Swift.AnyObject]) -> Swift.Bool (AppDelegate.swift:0)2 UIKit 0x000000018c1ee664 0x18bf34000 + 28606443 UIKit 0x000000018c1ee168 0x18bf34000 + 28593684 UIKit 0x000000018c1f5c30 0x18bf34000 + 28908005 UIKit 0x000000018c1fb644 0x18bf34000 + 29138606 UIKit 0x000000018c1fa9dc 0x18bf34000 + 29106847 UIKit 0x000000018c1e6fd4 0x18bf34000 + 28302928 UIKit 0x000000018c1e6eb4 0x18bf34000 + 28300049 FrontBoardServices 0x00000001905ffbe0 0x1905d8000 + 16278410 FrontBoardServices 0x00000001905fff60 0x1905d8000 + 16368011 CoreFoundation 0x00000001868eb8b4 0x18680c000 + 91563612 CoreFoundation 0x00000001868eb348 0x18680c000 + 91424813 CoreFoundation 0x00000001868e901c 0x18680c000 + 90524414 CoreFoundation 0x00000001868157fc 0x18680c000 + 3890815 GraphicsServices 0x00000001918a316c 0x191898000 + 4542016 UIKit 0x000000018bfae5e4 0x18bf34000 + 50122017 Some app 0x000000010005eaa4 main (AppDelegate.swift:14)18 libdyld.dylib 0x000000019bb128b4 0x19bb10000 + 10420It seems that when Facebook calls back my app the crash occurs in the openURL method of my AppDelegate. As mentioned above there are two ways to code this method as of iOS9 and I tried both. If I remove the Facebook code inside the method then I do not crash but I do not log In. So the line that crashes is Facebook's line. And it only crashes if my app was installed from an archive. Any ideas? Maybe Facebook's SDK has a bug on this particular case? 解决方案 I have found my answerLooks like it was a Release Mode only issue. By enabling Xcode to run Release builds I was able to debug my issue. It was caused by the parameter sourceApplication that apparently needs to be unwrapped when in release mode. No idea why, but at least I got it to work.func application(app: UIApplication, openURL url: NSURL, options: [String : AnyObject]) -> Bool{ return FBSDKApplicationDelegate.sharedInstance().application( app, openURL: url, sourceApplication: options["UIApplicationOpenURLOptionsSourceApplicationKey"] as! String, annotation: nil)} 这篇关于openURL崩溃:iOS 9中可能存在Facebook SDK错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-12 21:03