openURL 崩溃:iOS 9 中可能存在 Facebook SDK 错误
Crash in openURL: Possible Facebook SDK bug in iOS 9
上下文
我在我的应用程序中使用 FBSDKLoginButton
。我使用的是 Xcode 7.0,我的 iPhone 是 运行ning iOS 9 beta 3。我按照 Facebook 显示的每个步骤(创建应用程序等)进行操作并按照步骤操作用于添加 https://developers.facebook.com/docs/facebook-login/ios#login-button.
中的按钮
因为我在 iOS 9,所以我不得不对 info.plist
文件添加一些小改动以启用跨应用程序打开:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbauth</string>
</array>
并且由于 UIAppDelegate
中的 openURL
方法在 iOS9 上更改,我更改了 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 图表获取用户数据)当我 运行 来自模拟器的应用程序或直接在我的 iPhone 来自XCode,我 在我 运行 与我的应用程序 相同的过程时遇到问题,但这次是从存档安装的 .我尝试过使用存档的 IPA 文件从 OTA 应用程序或与 Xcode 管理器一起安装的应用程序。在这两种情况下,当 Facebook returns 返回我的应用程序 时,我都会遇到崩溃 。因为我不能使用 Xcode 的调试器,所以我只有一个崩溃日志。
Incident Identifier: 842E980C-8DE0-485F-8B3E-8CD889D34B3B
CrashReporter Key: 3e77866746471e437b9174c6082fc9136a18514f
Hardware Model: iPhone7,2
Process: Process Name [1086]
Path: /private/var/mobile/Containers/Bundle/Application/AA43C098-DFC0-483C-A073-C2401078E9FC/Some App.app/someapp
Identifier: fr.someapp.Some-App
Version: 1 (1.0)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
Date/Time: 2015-07-19 20:18:41.41 +0200
Launch Time: 2015-07-19 20:18:35.35 +0200
OS Version: iOS 9.0 (13A4293g)
Report Version: 105
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000010005f6e4
Triggered by Thread: 0
Filtered syslog:
None found
Global Trace Buffer (reverse chronological seconds):
0.228132 AppleJPEG 0x000000018dba5008 [0x13e871e00] Decoding completed without errors
0.250546 AppleJPEG 0x000000018dba31a0 [0x13e871e00] Options: 1080x1920 [FFFFFFFF,FFFFFFFF] 00025060
0.250629 AppleJPEG 0x000000018dba3058 [0x13e871e00] Decoding: C0 0x04380780 0x0044304A 0x22111100 0x00000000 175592
0.256474 AppleJPEG 0x000000018dba5008 [0x13e867200] Decoding completed without errors
0.261051 AppleJPEG 0x000000018dba31a0 [0x13e867200] Options: 750x1334 [FFFFFFFF,FFFFFFFF] 00025060
0.261101 AppleJPEG 0x000000018dba3058 [0x13e867200] Decoding: C0 0x02EE0536 0x002F304A 0x22111100 0x00000000 75882
0.262141 AppleJPEG 0x000000018dba5008 [0x13e85c600] Decoding completed without errors
0.272075 AppleJPEG 0x000000018dba31a0 [0x13e85c600] Options: 750x1334 [FFFFFFFF,FFFFFFFF] 00025060
0.272281 AppleJPEG 0x000000018dba3058 [0x13e85c600] Decoding: C0 0x02EE0536 0x002F304A 0x22111100 0x00000000 108826
0.273070 AppleJPEG 0x000000018dba5008 [0x13f04bc00] Decoding completed without errors
0.283798 AppleJPEG 0x000000018dba31a0 [0x13f04bc00] Options: 750x1334 [FFFFFFFF,FFFFFFFF] 00025060
0.283798 AppleJPEG 0x000000018dba3058 [0x13f04bc00] Decoding: C0 0x02EE0536 0x002F304A 0x22111100 0x00000000 72967
5.783070 CFNetwork 0x0000000186041d44 TCP Conn 0x13e5a1b90 SSL Handshake DONE
5.874750 CFNetwork 0x0000000186041c54 TCP Conn 0x13e5a1b90 starting SSL negotiation
5.875481 CFNetwork 0x00000001860e0e14 TCP Conn 0x13e5a1b90 complete. fd: 6, err: 0
5.876954 CFNetwork 0x00000001860e21e4 TCP Conn 0x13e5a1b90 event 1. err: 0
5.984181 CFNetwork 0x00000001860e22f8 TCP Conn 0x13e5a1b90 started
5.992333 CFNetwork 0x0000000186137140 Creating default cookie storage with default identifier
5.992333 CFNetwork 0x000000018613710c Faulting in CFHTTPCookieStorage singleton
5.992562 CFNetwork 0x0000000186188068 Faulting in NSHTTPCookieStorage singleton
6.189612 AppleJPEG 0x000000018dba234c [0x13e871e00] Created session
6.190797 AppleJPEG 0x000000018dba234c [0x13e867200] Created session
6.192109 AppleJPEG 0x000000018dba234c [0x13e85c600] Created session
6.197484 AppleJPEG 0x000000018dba234c [0x13f04bc00] Created session
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 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 + 2860644
3 UIKit 0x000000018c1ee168 0x18bf34000 + 2859368
4 UIKit 0x000000018c1f5c30 0x18bf34000 + 2890800
5 UIKit 0x000000018c1fb644 0x18bf34000 + 2913860
6 UIKit 0x000000018c1fa9dc 0x18bf34000 + 2910684
7 UIKit 0x000000018c1e6fd4 0x18bf34000 + 2830292
8 UIKit 0x000000018c1e6eb4 0x18bf34000 + 2830004
9 FrontBoardServices 0x00000001905ffbe0 0x1905d8000 + 162784
10 FrontBoardServices 0x00000001905fff60 0x1905d8000 + 163680
11 CoreFoundation 0x00000001868eb8b4 0x18680c000 + 915636
12 CoreFoundation 0x00000001868eb348 0x18680c000 + 914248
13 CoreFoundation 0x00000001868e901c 0x18680c000 + 905244
14 CoreFoundation 0x00000001868157fc 0x18680c000 + 38908
15 GraphicsServices 0x00000001918a316c 0x191898000 + 45420
16 UIKit 0x000000018bfae5e4 0x18bf34000 + 501220
17 Some app 0x000000010005eaa4 main (AppDelegate.swift:14)
18 libdyld.dylib 0x000000019bb128b4 0x19bb10000 + 10420
似乎当 Facebook 回调我的应用程序时,崩溃发生在我的 AppDelegate
的 openURL
方法中。如上所述,从 iOS9 开始,有两种方法可以对此方法进行编码,我两种方法都试过了。如果我删除方法中的 Facebook 代码,那么我不会崩溃,但我不会登录。所以崩溃的线路是 Facebook 的线路。如果我的应用程序是从存档安装的,它只会崩溃。有任何想法吗?也许 Facebook 的 SDK 在这种特殊情况下存在错误?
我找到答案了
看起来这只是 发布模式 的问题。通过启用 Xcode 到 运行 发布版本,我能够调试我的问题。这是由参数 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)
}
上下文
我在我的应用程序中使用 FBSDKLoginButton
。我使用的是 Xcode 7.0,我的 iPhone 是 运行ning iOS 9 beta 3。我按照 Facebook 显示的每个步骤(创建应用程序等)进行操作并按照步骤操作用于添加 https://developers.facebook.com/docs/facebook-login/ios#login-button.
因为我在 iOS 9,所以我不得不对 info.plist
文件添加一些小改动以启用跨应用程序打开:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>fbauth</string>
</array>
并且由于 UIAppDelegate
中的 openURL
方法在 iOS9 上更改,我更改了 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 图表获取用户数据)当我 运行 来自模拟器的应用程序或直接在我的 iPhone 来自XCode,我 在我 运行 与我的应用程序 相同的过程时遇到问题,但这次是从存档安装的 .我尝试过使用存档的 IPA 文件从 OTA 应用程序或与 Xcode 管理器一起安装的应用程序。在这两种情况下,当 Facebook returns 返回我的应用程序 时,我都会遇到崩溃 。因为我不能使用 Xcode 的调试器,所以我只有一个崩溃日志。
Incident Identifier: 842E980C-8DE0-485F-8B3E-8CD889D34B3B
CrashReporter Key: 3e77866746471e437b9174c6082fc9136a18514f
Hardware Model: iPhone7,2
Process: Process Name [1086]
Path: /private/var/mobile/Containers/Bundle/Application/AA43C098-DFC0-483C-A073-C2401078E9FC/Some App.app/someapp
Identifier: fr.someapp.Some-App
Version: 1 (1.0)
Code Type: ARM-64 (Native)
Parent Process: launchd [1]
Date/Time: 2015-07-19 20:18:41.41 +0200
Launch Time: 2015-07-19 20:18:35.35 +0200
OS Version: iOS 9.0 (13A4293g)
Report Version: 105
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000010005f6e4
Triggered by Thread: 0
Filtered syslog:
None found
Global Trace Buffer (reverse chronological seconds):
0.228132 AppleJPEG 0x000000018dba5008 [0x13e871e00] Decoding completed without errors
0.250546 AppleJPEG 0x000000018dba31a0 [0x13e871e00] Options: 1080x1920 [FFFFFFFF,FFFFFFFF] 00025060
0.250629 AppleJPEG 0x000000018dba3058 [0x13e871e00] Decoding: C0 0x04380780 0x0044304A 0x22111100 0x00000000 175592
0.256474 AppleJPEG 0x000000018dba5008 [0x13e867200] Decoding completed without errors
0.261051 AppleJPEG 0x000000018dba31a0 [0x13e867200] Options: 750x1334 [FFFFFFFF,FFFFFFFF] 00025060
0.261101 AppleJPEG 0x000000018dba3058 [0x13e867200] Decoding: C0 0x02EE0536 0x002F304A 0x22111100 0x00000000 75882
0.262141 AppleJPEG 0x000000018dba5008 [0x13e85c600] Decoding completed without errors
0.272075 AppleJPEG 0x000000018dba31a0 [0x13e85c600] Options: 750x1334 [FFFFFFFF,FFFFFFFF] 00025060
0.272281 AppleJPEG 0x000000018dba3058 [0x13e85c600] Decoding: C0 0x02EE0536 0x002F304A 0x22111100 0x00000000 108826
0.273070 AppleJPEG 0x000000018dba5008 [0x13f04bc00] Decoding completed without errors
0.283798 AppleJPEG 0x000000018dba31a0 [0x13f04bc00] Options: 750x1334 [FFFFFFFF,FFFFFFFF] 00025060
0.283798 AppleJPEG 0x000000018dba3058 [0x13f04bc00] Decoding: C0 0x02EE0536 0x002F304A 0x22111100 0x00000000 72967
5.783070 CFNetwork 0x0000000186041d44 TCP Conn 0x13e5a1b90 SSL Handshake DONE
5.874750 CFNetwork 0x0000000186041c54 TCP Conn 0x13e5a1b90 starting SSL negotiation
5.875481 CFNetwork 0x00000001860e0e14 TCP Conn 0x13e5a1b90 complete. fd: 6, err: 0
5.876954 CFNetwork 0x00000001860e21e4 TCP Conn 0x13e5a1b90 event 1. err: 0
5.984181 CFNetwork 0x00000001860e22f8 TCP Conn 0x13e5a1b90 started
5.992333 CFNetwork 0x0000000186137140 Creating default cookie storage with default identifier
5.992333 CFNetwork 0x000000018613710c Faulting in CFHTTPCookieStorage singleton
5.992562 CFNetwork 0x0000000186188068 Faulting in NSHTTPCookieStorage singleton
6.189612 AppleJPEG 0x000000018dba234c [0x13e871e00] Created session
6.190797 AppleJPEG 0x000000018dba234c [0x13e867200] Created session
6.192109 AppleJPEG 0x000000018dba234c [0x13e85c600] Created session
6.197484 AppleJPEG 0x000000018dba234c [0x13f04bc00] Created session
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 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 + 2860644
3 UIKit 0x000000018c1ee168 0x18bf34000 + 2859368
4 UIKit 0x000000018c1f5c30 0x18bf34000 + 2890800
5 UIKit 0x000000018c1fb644 0x18bf34000 + 2913860
6 UIKit 0x000000018c1fa9dc 0x18bf34000 + 2910684
7 UIKit 0x000000018c1e6fd4 0x18bf34000 + 2830292
8 UIKit 0x000000018c1e6eb4 0x18bf34000 + 2830004
9 FrontBoardServices 0x00000001905ffbe0 0x1905d8000 + 162784
10 FrontBoardServices 0x00000001905fff60 0x1905d8000 + 163680
11 CoreFoundation 0x00000001868eb8b4 0x18680c000 + 915636
12 CoreFoundation 0x00000001868eb348 0x18680c000 + 914248
13 CoreFoundation 0x00000001868e901c 0x18680c000 + 905244
14 CoreFoundation 0x00000001868157fc 0x18680c000 + 38908
15 GraphicsServices 0x00000001918a316c 0x191898000 + 45420
16 UIKit 0x000000018bfae5e4 0x18bf34000 + 501220
17 Some app 0x000000010005eaa4 main (AppDelegate.swift:14)
18 libdyld.dylib 0x000000019bb128b4 0x19bb10000 + 10420
似乎当 Facebook 回调我的应用程序时,崩溃发生在我的 AppDelegate
的 openURL
方法中。如上所述,从 iOS9 开始,有两种方法可以对此方法进行编码,我两种方法都试过了。如果我删除方法中的 Facebook 代码,那么我不会崩溃,但我不会登录。所以崩溃的线路是 Facebook 的线路。如果我的应用程序是从存档安装的,它只会崩溃。有任何想法吗?也许 Facebook 的 SDK 在这种特殊情况下存在错误?
我找到答案了
看起来这只是 发布模式 的问题。通过启用 Xcode 到 运行 发布版本,我能够调试我的问题。这是由参数 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)
}