From 77a52587582a2371e9e251977ad2c887489eb379 Mon Sep 17 00:00:00 2001 From: Mohamed Abdallah Date: Tue, 28 Apr 2026 21:29:41 +0300 Subject: [PATCH] fix(share_plus): avoid iOS 26 share sheet crash for non-image files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../Sources/share_plus/FPPSharePlusPlugin.m | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/share_plus/share_plus/ios/share_plus/Sources/share_plus/FPPSharePlusPlugin.m b/packages/share_plus/share_plus/ios/share_plus/Sources/share_plus/FPPSharePlusPlugin.m index 15230453e2..0efe75b18c 100644 --- a/packages/share_plus/share_plus/ios/share_plus/Sources/share_plus/FPPSharePlusPlugin.m +++ b/packages/share_plus/share_plus/ios/share_plus/Sources/share_plus/FPPSharePlusPlugin.m @@ -247,7 +247,19 @@ - (LPLinkMetadata *)activityViewControllerLinkMetadata: } // https://stackoverflow.com/questions/60563773/ios-13-share-sheet-changing-subtitle-item-description - metadata.originalURL = [NSURL fileURLWithPath:description]; + // The fake file URL above is a long-standing trick used to surface the + // file size/extension as a subtitle in the share sheet. iOS 26 introduced + // stricter validation of LPLinkMetadata.originalURL: when the share sheet + // tries to fetch link metadata (SHSheetActivityItemsManager) for the + // bogus URL — for example when sharing .docx files — it crashes with + // "*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil". + // Skip the fake URL on iOS 26+ and accept the loss of the subtitle in + // exchange for not crashing. See issue #3784. + if (@available(iOS 26.0, *)) { + // Leave metadata.originalURL nil. + } else { + metadata.originalURL = [NSURL fileURLWithPath:description]; + } if (_mimeType && [_mimeType hasPrefix:@"image/"]) { UIImage *image = [UIImage imageWithContentsOfFile:_path]; metadata.imageProvider = [[NSItemProvider alloc]