You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On iOS 26 (26.3.1), sharing a DOCX file via SharePlus.shareXFiles() crashes with NSArrayM insertObject:atIndex: object cannot be nil inside SHSheetActivityItemsManager. This crash is consistently triggered by sharing .docx files and does not reproduce when sharing .pdf or plain text.
Steps to Reproduce
Create an XFile with path to a .docx file and mimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'
The crash occurs inside iOS's SHSheetActivityItemsManager, which powers sharing suggestions (top contacts, suggested share targets) on the share sheet. It asynchronously loads LPLinkMetadata for each shared item, and the code attempts to insert the fetched metadata into an NSMutableArray — but the metadata or one of its properties is nil.
Root Cause Analysis
The iOS 16+ share sheet uses LPLinkPreview to generate rich previews. It calls UIActivityItemSource.activityViewControllerLinkMetadata(_:) to get an LPLinkMetadata object. In FPPSharePlusPlugin.m, the plugin sets:
metadata.originalURL = [NSURLfileURLWithPath:description];
// where description = @"DOCX • 500 KB" (a display string, not a valid path)
This creates a fileURL with a path like file:///DOCX%20%E2%80%A2%20500%20KB which is not a real file URL. iOS 26 introduced stricter validation of LPLinkMetadata.originalURL for non-image file types. When SHSheetActivityItemsManager tries to fetch link metadata for this garbage URL, LPLinkPreview returns a nil or incomplete metadata object, and _updateMetadataItemForActivityItem:withFetchedMetadata: attempts to insert that nil object into its internal NSMutableArray, causing the crash.
The issue appears to be specific to file types that iOS 26 tries to preview/suggest-for (e.g., DOCX), whereas PDF sharing does not trigger it in our testing (PDFs may be handled by a different code path internally).
Workaround
We have not found a reliable client-side workaround. Setting metadata.originalURL = nil instead of the fake path may help. Removing the activityViewControllerLinkMetadata implementation entirely in the plugin would also prevent the crash, at the cost of rich preview metadata.
Environment
share_plus version: 12.0.1
Flutter version: 3.41.2
Dart version: 3.7.0
iOS version affected: 26.3.1 (iOS 26 beta)
iOS versions not affected: 17.x and earlier (confirmed working)
35 crash events / week, affecting ~20 users in production. iOS 26 represents ~85% of our iOS crash volume.
Additional Context
The plugin file at fault is share_plus/ios/share_plus/Sources/share_plus/FPPSharePlusPlugin.m in the activityViewControllerLinkMetadata: implementation of SharePlusData.
Description
On iOS 26 (26.3.1), sharing a DOCX file via
SharePlus.shareXFiles()crashes withNSArrayM insertObject:atIndex: object cannot be nilinsideSHSheetActivityItemsManager. This crash is consistently triggered by sharing.docxfiles and does not reproduce when sharing.pdfor plain text.Steps to Reproduce
XFilewith path to a.docxfile andmimeType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document'SharePlus.instance.shareXFiles([xFile], sharePositionOrigin: someRect)Expected Behavior
Share sheet opens without crashing (works correctly on iOS 17 and earlier).
Actual Behavior
Fatal crash with the following stack trace:
The crash occurs inside iOS's
SHSheetActivityItemsManager, which powers sharing suggestions (top contacts, suggested share targets) on the share sheet. It asynchronously loadsLPLinkMetadatafor each shared item, and the code attempts to insert the fetched metadata into anNSMutableArray— but the metadata or one of its properties isnil.Root Cause Analysis
The iOS 16+ share sheet uses
LPLinkPreviewto generate rich previews. It callsUIActivityItemSource.activityViewControllerLinkMetadata(_:)to get anLPLinkMetadataobject. InFPPSharePlusPlugin.m, the plugin sets:This creates a
fileURLwith a path likefile:///DOCX%20%E2%80%A2%20500%20KBwhich is not a real file URL. iOS 26 introduced stricter validation ofLPLinkMetadata.originalURLfor non-image file types. WhenSHSheetActivityItemsManagertries to fetch link metadata for this garbage URL,LPLinkPreviewreturns anilor incomplete metadata object, and_updateMetadataItemForActivityItem:withFetchedMetadata:attempts to insert that nil object into its internalNSMutableArray, causing the crash.The issue appears to be specific to file types that iOS 26 tries to preview/suggest-for (e.g., DOCX), whereas PDF sharing does not trigger it in our testing (PDFs may be handled by a different code path internally).
Workaround
We have not found a reliable client-side workaround. Setting
metadata.originalURL = nilinstead of the fake path may help. Removing theactivityViewControllerLinkMetadataimplementation entirely in the plugin would also prevent the crash, at the cost of rich preview metadata.Environment
Related Issues
sharePositionOrigin(different crash, same iOS version context)sharePositionOrigin must be set(different crash)Crash Frequency
35 crash events / week, affecting ~20 users in production. iOS 26 represents ~85% of our iOS crash volume.
Additional Context
The plugin file at fault is
share_plus/ios/share_plus/Sources/share_plus/FPPSharePlusPlugin.min theactivityViewControllerLinkMetadata:implementation ofSharePlusData.