When I write code in shareExtension like below: dispatch_async(dispatch_get_global_queue(0, 0), ^{ UIResponder *responder = [self nextResponder]; while ((responder = [responder nextResponder]) != nil) { if ([responder respondsToSelector:@selector(openURL:)] == YES) { [responder performSelector:@selector(openURL:) withObject:[NSURL URLWithString:APP_SCHEME]]; break; } } });
Will output in the console:
BUG IN CLIENT OF UIKIT: The caller of UIApplication.openURL(:) needs to migrate to the non-deprecated UIApplication.open(:options:completionHandler:). Force returning false (NO).
Looking on the bright side of things, you’ve learnt a key compatibility lesson. Sadly, you had to learn that the hard way )-:
The UIApplication
object is explicitly marked as unavailable from an app extension. If you add code to an app extension that tries to open a URL in the normal way, using UIApplication.shared.open(_:)
, it’ll fail to build. You’ve used the Objective-C runtime to bypass that build-time restriction, and that’s now failing.
App extensions are not allowed to open URLs directly. This isn’t accidental, but a deliberate design choice on Apple’s part. Don’t try to bypass such restrictions using Silly Runtime Hacks™. That just opens yourself up to compatibility problems down the pike.
If your app extension needs to get the user’s attention, do that by posting a local notification.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"