Mac Catalyst: Share sheet not working correctly

I'm 'porting' an iPad app to MacOS using Mac Catalyst, and I'm having trouble getting the document share sheet to work properly.

I've tried two ways and they both result in the same thing: no share sheet appears, but only a little popup with a "More..." button (see image).

Attempt #1: using a UIDocumentInteractionController...

NSURL* url = [NSURL fileURLWithPath:fileToShare];
UIDocumentInteractionController* docController = [UIDocumentInteractionController interactionControllerWithURL:url];
[docController presentPreviewAnimated:YES];
[docController presentOptionsMenuFromRect:CGRectMake(x, y, 0, 0) inView:currentView animated:YES];

Attempt #2: using a UIActivityViewController...

NSURL* url = [NSURL fileURLWithPath:fileToShare];
NSArray* shareData = @[url];
UIActivityViewController* activityController = [[UIActivityViewController alloc] initWithActivityItems:shareData applicationActivities:nil];
[self presentViewController:activityController animated:YES completion:NULL];

Since both mechanisms consistently give the same result (both work on iOS and not on MacOS), I have a feeling I need to set some kind of permission or entitlement to get this working on MacOS. But I can't find any hints or documentation to support this.

Replies

Both of these examples should work if you have read access to the URL. Is the URL a file URL pointing to a location inside your app’s data container?

  • The URL is a file URL pointing to a location inside my Group Container: /Users/username/Library/Group Containers/group.com.username.appname/Temp

    I am using the Group Container because my share sheet is called from inside an AUv3 Extension sandbox. Would that make a difference compared to a 'regular' standalone app?

Add a Comment

Can your extension process read the file pointed to by the URL?

Does the URL end in a file extension that maps to a known Uniform Type Identifier?

If so, try using UIActivityItemsConfiguration instead, like so:

NSItemProvider *itemProvider = [[NSItemProvider alloc] initWithContentsOfURL:fileURL];
UIActivityItemsConfiguration *config = [[UIActivityItemsConfiguration alloc] initWithItemProviders:@[itemProvider]];
UIActivityViewController *uiavc = [[UIActivityViewController alloc] initWithActivityItemsConfiguration:config];
// Present uiavc