4

I'am getting some crashes on 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

Looks like to me like the reference got lost somehow? any idea?

I don't do anything special

- (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];

}

Note: it looks to me iOS11 related as i cannot recall having this issue before, also it was not tracked besides iOS11

Krunal
  • 77,632
  • 48
  • 245
  • 261
Peter Lapisu
  • 19,915
  • 16
  • 123
  • 179

2 Answers2

1

SLServiceTypeTwitter is removed in iOS 11. You need to use Twitter's own share solution to implement this functionality.

See this page for information about migrating to TwitterKit from your current solution: https://dev.twitter.com/twitterkit/ios/migrate-social-framework

donnywals
  • 7,241
  • 1
  • 19
  • 27
0

It seems that the view controller is accessed inside of the library after the view controller is deallocated. I guess it's a extension's bug.

Preserving the view controller might work for a workaround.

- (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;
        });
    }];
}
hotpepsi
  • 1
  • 1