iOS Share extension — Swift 5.1

Share contents into your app in a few easy steps.

Fabio Pelizzola
Mac O’Clock

--

Photo by Yura Fresh on Unsplash

“How the `hack` is Share Extension? How can I share contents into my app?” If you are wondering about one of these questions you are in the right place!

Share Extension is an easy way that Apple provides to share contents (images, audio, files, etc.) from one app to another, even made by different developers. You just need to follow a few simple steps and if you don’t know what’s an extension in the iOS world, you can just have a quick look here.

To follow this article it should be better to know what target and schemes are in Xcode and how they work but it’s not mandatory.

1. Add a Share Extension to your project

Go into the project section, click on the + button and select the Share extension from the list. Just call it Share or whatever name you prefer.

The system asks you if you want to activate the Share scheme , just select Activate. This is required because XCode creates a new Target with an associated scheme for the extension. You can see the new target in the target list.

--

--

Fabio Pelizzola
Mac O’Clock

Hi! I’m Fabio, iOS Engineer from Italy with a passion for travelling and playing music. IG: fab_p93