Sharing App Data with Uniform Type Identifiers and ShareSheets Part 2

Опубликовано: 25 Июль 2026
на канале: Stewart Lynch
695
38

In part two of this series, we complete the workflow for sharing SwiftData content between different users of the same app.

We start by letting the user name their export file and present a UIKit-based share sheet from SwiftUI. Because the data is generated dynamically based on the user’s current selection, ShareLink is not an option, so we bridge to UIActivityViewController using UIViewControllerRepresentable.

From there, we handle the incoming BKLS file when the app is launched or brought to the foreground. Using onOpenURL, we decode the shared JSON, manage security-scoped resources, and import books, authors, and genres into SwiftData while preventing duplicates.

This video shows how to safely merge relational data from an external file, link models correctly, and support real-world sharing scenarios like AirDrop, Files, and Mail.

If you want to support my work, you can buy me a coffee :) 
https://ko-fi.com/stewartlynch/

My Newsletter
https://stewartlynch.kit.com

Channel Listing Mac App (Free)
https://stewartlynch.gumroad.com/l/obsjz

Channel Listing Web App 
https://stewartlynch.github.io/YouTube/

Table of Contents: 
0:00  Introduction
1:55 UIActivityViewController ShareSheet
5:52 ShareSheet Button
14:00 Handling Sharing Notification
16:43 Import Function
28:18 Testing Sharing

 Starter Project Files: https://github.com/StewartLynch/MyBoo...
Completed Project: https://github.com/StewartLynch/MyBoo...

References mentioned in video: 
SwiftUI ShareLinks
   • ShareLink and ShareSheet in iOS 16  

Recommended Resources: 
Big Mountain Studio Books 
AI Mastery in SwiftUI
https://www.bigmountainstudio.com/ai-...
SwiftUI Views Mastery
https://www.bigmountainstudio.com/adv...
Advanced SwiftUI Views Mastery 
   https://www.bigmountainstudio.com/adv...
SwiftUI Animations Mastery
https://www.bigmountainstudio.com/ani...
SwiftData Mastery in SwiftUI 
   https://www.bigmountainstudio.com/swi...
Combine Mastery in SwiftUI 
https://www.bigmountainstudio.com/com...
SwiftUI 5 Book Bundle 
   https://www.bigmountainstudio.com/boo...