How gwan-son/linkclip works
Project Type and Purpose
• Project type: Native iOS application with a Share Extension
• Purpose: Let users save and organize web links (LinkClip), both from within the app and via the iOS share sheet.
Main Components
a. Host App (“LinkClip”)
– SwiftUI-based UI modules:
• MainView (HomeView, EditView, OnboardingView, LinkRowView, NothingView)
• CategoryView (AddCategoryView, CategoryManagementView, CategoryView)
• SettingView (SettingView, MailView)
• Shared SwiftUI views (ShareView.swift used in both host and extension)
– ViewModel: MainViewModel (MVVM)
– Model / Data Layer:
• SwiftDataContainer.swift (encapsulates persistence)
• Entities: Category, LinkItem, SearchScope, SortOption
– Utilities: ToastModifier, ShareError
– Assets: AppIcon, AccentColor, BackgroundColor, MainColor, SettingImage
b. Share Extension (“ShareViewController”)
– UIKit UIViewController (ShareViewController.swift)
– Uses same SwiftDataContainer via App Group entitlement
– Presents minimal UI to name/link and save into the host app’s store
c. Persistence & Data Flow
– SwiftData (or Core Data under the hood) storing LinkItem & Category objects
– App Group container for sharing the persistent store between host and extension
– Entitlements files: LinkClip.entitlements & ShareViewController.entitlements
d. External / System Services
– iOS Share Sheet API
– File system (App Group directory)
– Mail composer (in SettingView)
Architectural Patterns & Design Principles
• MVVM: Views ↔ ViewModel ↔ Model
• Single Data Container: SwiftDataContainer acts as the façade for all persistence operations
• Separation of Concerns:
– UI modules (MainView, CategoryView, SettingView) do not perform direct store access; they call into ViewModel → SwiftDataContainer
– Share extension isolated in its own target, shares code but has separate entitlements
• Reusable Components: Category.swift, LinkItem.swift, ToastModifier.swift, ShareView.swift
Relationships & Data Flows
1. User taps “Add Link” in Host App
→ MainViewModel receives action
→ Calls SwiftDataContainer.save(linkItem)
→ SwiftDataContainer writes to persistent store in App Group
→ MainViewModel publishes updated list → MainView updates UI
2. User invokes Share Extension from Safari
→ iOS launches ShareViewController
→ User enters category or link details in ShareView (SwiftUI hosted)
→ ShareViewController calls SwiftDataContainer.save(…) over the App Group store
→ Dismiss extension → Host App sees new item on next launch