FBSDKShareDialog 崩溃:[__NSCFString 方案]

FBSDKShareDialog CRASH: [__NSCFString scheme]

执行这段代码时

FBSDKShareDialog *dialog = [[FBSDKShareDialog alloc] init];
dialog.fromViewController = viewController;
dialog.shareContent = content;
dialog.mode = FBSDKShareDialogModeFeedWeb;
dialog.delegate = self;
[dialog show];

应用程序在 [对话框显示] 时崩溃;使用此堆栈跟踪:

0   CoreFoundation                      0x2b9effa7 <redacted> + 150
1   libobjc.A.dylib                     0x3a0a0c8b objc_exception_throw + 38
2   CoreFoundation                      0x2b9f53a9 <redacted> + 0
3   CoreFoundation                      0x2b9f32c7 <redacted> + 714
4   CoreFoundation                      0x2b922ba8 _CF_forwarding_prep_0 + 24
5   uCiC                                0x003cf1ef +[FBSDKInternalUtility isBrowserURL:] + 22
6   uCiC                                0x0044c9f5 +[FBSDKShareUtility _validateNetworkURL:name:error:] + 64
7   uCiC                                0x0044b17d +[FBSDKShareUtility validateShareLinkContent:error:] + 176
8   uCiC                                0x0044ad71 +[FBSDKShareUtility validateShareContent:error:] + 284
9   uCiC                                0x004433ad -[FBSDKShareDialog validateWithError:] + 84
10  uCiC                                0x004431c5 -[FBSDKShareDialog show] + 36
11  uCiC                                0x002028c7 -[ICSocialSharer fbSharingInAppWebViewContent:inViewController:] + 306
12  uCiC                                0x002031f5 -[ICSocialSharer fbSharingForPostModel:inViewController:] + 2316
13  uCiC                                0x00203549 -[ICSocialSharer postMessageForModel:socialNetwork:inViewController:] + 568
14  uCiC                                0x000ea2e5 -[PostFotoViewController postSocial:] + 1528
15  UIKit                               0x2f0a2c4b <redacted> + 70
16  UIKit                               0x2f0a2bf1 <redacted> + 44
17  UIKit                               0x2f08d7e3 <redacted> + 582
18  UIKit                               0x2f0a265d <redacted> + 588
19  UIKit                               0x2f0a2337 <redacted> + 522
20  UIKit                               0x2f09bc11 <redacted> + 544
21  UIKit                               0x2f071e05 <redacted> + 196
22  UIKit                               0x2f2e86fb <redacted> + 14414
23  UIKit                               0x2f070819 <redacted> + 1352
24  CoreFoundation                      0x2b9b5d8f <redacted> + 14
25  CoreFoundation                      0x2b9b519f <redacted> + 218
26  CoreFoundation                      0x2b9b3805 <redacted> + 772
27  CoreFoundation                      0x2b8fff31 CFRunLoopRunSpecific + 476
28  CoreFoundation                      0x2b8ffd43 CFRunLoopRunInMode + 106
29  GraphicsServices                    0x333da201 GSEventRunModal + 136
30  UIKit                               0x2f0d1879 UIApplicationMain + 1440
31  uCiC                                0x0010d07d main + 108
32  libdyld.dylib                       0x3a652aaf <redacted> + 2

原因是:'-[__NSCFString 方案]:无法识别的选择器发送到实例 0x187a8030'。

发生这种情况是因为我们使用 iOS9 构建。

现在,plist 包含适用于 FaceBookSDK 4.6 的正确方案,并且允许 AppTranspotPolicy。

你们知道如何解决这个问题吗?

谢谢, D.

显然 Facebook 不会检查内容 url 是否实际上是 url,即使对象是 NSString,他们也会调用 [NSURL scheme]。

所以内容图片url是这样写的,编译器没有任何警告或问题:

content.imageURL = [sharedData valueForKey:@"link"];  //which is an NSString

然后像这样把它变成一个 NSURL

content.imageURL = [NSURL URLWithString:[sharedData valueForKey:@"link"]];

似乎一切正常。

非常糟糕,因为编译器没有报错,但应用程序在运行时崩溃了。我也会在 Facebook 上提交错误。

PS:我已经在这里写了这篇文章,供任何遇到此问题的人使用。