share
Hand something to the rest of the system — the platform's own sheet.
[dependencies]
share = "*"
import "share/share" as sh;
sh::text("look at this");
sh::url("https://example.com/thing");
sh::file("/path/to/report.pdf");
macOS, iOS, Android and Windows. Linux builds and reports Unsupported because
the desktop has no system share-sheet service. On Windows it goes through WinRT's
DataTransferManager reached as plain COM, and it needs a window and a
running message loop — the sheet asks for the payload later, on that loop.
file() is Unsupported there and on Android; the guide says why.
The return value is "the sheet opened"
Never "the person shared". No platform reports reliably which app was chosen or whether the send completed — iOS's completion handler reports cancellation but lies about success for several targets, and Android's chooser reports nothing at all. An app that needs to know something was sent has to observe the result itself.
Three verbs, not one with a kind
A URL gets a preview card, a different app list and "Copy Link" instead of "Copy". A file goes through a provider a string never touches. A caller who has a URL should say so.
Coverage
| macOS | iOS | Android | Linux | Windows | |
|---|---|---|---|---|---|
text |
✅ | ✅ | ✅ | ❌ Unsupported |
✅ |
url |
✅ real NSURL |
✅ real NSURL |
✅ as text | ❌ Unsupported |
✅ real Uri |
file |
✅ | ✅ | ❌ needs an app-level FileProvider |
❌ Unsupported |
❌ not built |
subject |
dropped | dropped | ✅ EXTRA_SUBJECT |
— | used as title |
Tests
cd vendor/share && cpc test
A sheet cannot be asserted — it needs eyes.