iOS 16 ShareLink — native share sheet in SwiftUI

Atikur Rahman
Evangelist Apps Blog
2 min readAug 1, 2022

In earlier versions of SwiftUI, there was no native support to show share sheets. We had to wrap UIActivityController to UIViewRepresentable in order to show a share sheet. But in iOS 16, SwiftUI comes with a new view called ShareLink, which allows us to create a native share sheet with ease.

Using ShareLink, you can share any kind of data from your app. Let’s take a look at few examples.

First, we will see how to share text.

As you can see, you simply pass a string to the item parameter. This will render a Share button with a small icon. When you tap the Share button, a share sheet will popup.

To share an URL, we can pass the url to the item parameter.

You can easily customize the appearance of the Share button. You simply need to provide a view content in the closure as follows -

Which will render the following share button.

pic credit: Unknown

Please share your thoughts and suggestions on this article.

Keep up with us on social media:

LinkedIn: https://www.linkedin.com/company/evangelist-apps-limited/

Twitter: https://twitter.com/EvangelistSW

--

--