崩溃[SLComposeViewController initWithExtension:requestedServiceType:] _ block_invoke + 84

时间:2017-11-01 13:01:51

标签: ios cocoa-touch ios11 slcomposeviewcontroller

我在SLComposeViewController

上遇到了一些崩溃
Crashed: com.apple.extension.global-state-queue
0  libobjc.A.dylib                0x18167cbb4 objc_loadWeakRetained + 156
1  libobjc.A.dylib                0x18167cd64 objc_copyWeak + 24
2  Social                         0x1933abdbc __66-[SLComposeViewController initWithExtension:requestedServiceType:]_block_invoke + 84
3  Foundation                     0x182b30b04 __85-[NSExtension _completeRequestReturningItems:forExtensionContextWithUUID:completion:]_block_invoke + 108
4  libdispatch.dylib              0x181ad1088 _dispatch_call_block_and_release + 24
5  libdispatch.dylib              0x181ad1048 _dispatch_client_callout + 16
6  libdispatch.dylib              0x181adae48 _dispatch_queue_serial_drain$VARIANT$mp + 528
7  libdispatch.dylib              0x181adb7d8 _dispatch_queue_invoke$VARIANT$mp + 340
8  libdispatch.dylib              0x181adc200 _dispatch_root_queue_drain_deferred_wlh$VARIANT$mp + 400
9  libdispatch.dylib              0x181ae44a0 _dispatch_workloop_worker_thread$VARIANT$mp + 644
10 libsystem_pthread.dylib        0x181d76fe0 _pthread_wqthread + 932
11 libsystem_pthread.dylib        0x181d76c30 start_wqthread + 4

看起来像我的参考文件以某种方式丢失了?任何想法?

我不做任何特别的事情

- (void)presentTwitterShareWithURL:(NSURL *)url {

    if (url == nil) {
        return;
    }

    SLComposeViewController * cvc = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
    [cvc addURL:url];

    [cvc setCompletionHandler:^(SLComposeViewControllerResult result) {

        if (SLComposeViewControllerResultDone == result) {

            [[Analytics shared] trackWithCategory:@"Web" action:@"Tap" label:@"Share - Twitter"];

        }

    }];

    [self.navigationController presentViewController:cvc animated:YES completion:nil];

}

注意:它看起来与iOS11相关,因为我以前不记得有这个问题,除了iOS11之外它也没有跟踪

2 个答案:

答案 0 :(得分:1)

在iOS 11中删除了

SLServiceTypeTwitter。您需要使用Twitter自己的共享解决方案来实现此功能。

有关从当前解决方案迁移到TwitterKit的信息,请参阅此页面:https://dev.twitter.com/twitterkit/ios/migrate-social-framework

答案 1 :(得分:0)

在取消分配视图控制器后,似乎在库内部访问了视图控制器。我想这是一个扩展的错误。

保留视图控制器可能适用于解决方法。

- (void)presentTwitterShareWithURL:(NSURL *)url {

    if (url == nil) {
        return;
    }

    __block SLComposeViewController * cvc = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
    [cvc addURL:url];

    [cvc setCompletionHandler:^(SLComposeViewControllerResult result) {

        if (SLComposeViewControllerResultDone == result) {

            [[Analytics shared] trackWithCategory:@"Web" action:@"Tap" label:@"Share - Twitter"];

        }

    }];

    [self.navigationController presentViewController:cvc animated:YES completion:^{
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            cvc = nil;
        });
    }];
}