Skip to content

Commit 77a5258

Browse files
fix(share_plus): avoid iOS 26 share sheet crash for non-image files
Fixes #3784. Pre-iOS 26 the plugin set LPLinkMetadata.originalURL to a fake file URL built from a display string (e.g. "DOCX • 500 KB") so the share sheet would show the file size/extension as a subtitle. iOS 26 tightened validation of originalURL: when SHSheetActivityItemsManager tries to fetch link metadata for the bogus URL — reproducible when sharing .docx files — it crashes with NSArrayM insertObject:atIndex: object cannot be nil. Gate the fake-URL trick on iOS < 26. On iOS 26 and later, leave originalURL unset; the share sheet works without the size subtitle but no longer crashes.
1 parent 6427bc6 commit 77a5258

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

packages/share_plus/share_plus/ios/share_plus/Sources/share_plus/FPPSharePlusPlugin.m

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,19 @@ - (LPLinkMetadata *)activityViewControllerLinkMetadata:
247247
}
248248

249249
// https://stackoverflow.com/questions/60563773/ios-13-share-sheet-changing-subtitle-item-description
250-
metadata.originalURL = [NSURL fileURLWithPath:description];
250+
// The fake file URL above is a long-standing trick used to surface the
251+
// file size/extension as a subtitle in the share sheet. iOS 26 introduced
252+
// stricter validation of LPLinkMetadata.originalURL: when the share sheet
253+
// tries to fetch link metadata (SHSheetActivityItemsManager) for the
254+
// bogus URL — for example when sharing .docx files — it crashes with
255+
// "*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil".
256+
// Skip the fake URL on iOS 26+ and accept the loss of the subtitle in
257+
// exchange for not crashing. See issue #3784.
258+
if (@available(iOS 26.0, *)) {
259+
// Leave metadata.originalURL nil.
260+
} else {
261+
metadata.originalURL = [NSURL fileURLWithPath:description];
262+
}
251263
if (_mimeType && [_mimeType hasPrefix:@"image/"]) {
252264
UIImage *image = [UIImage imageWithContentsOfFile:_path];
253265
metadata.imageProvider = [[NSItemProvider alloc]

0 commit comments

Comments
 (0)