Skip to main content

share-extension

Share extension with NSExtensionActivationRule filtering, SLComposeServiceViewController handling, App Group data sharing, and shared content processing for URLs, text, and images. Use when adding share sheet integration to an iOS app.

소스 정보

저장소
moasq/nanowave
최근 소스 활동
2026년 3월 27일 05:39
감지된 SKILL.md 언어
영어
스타
32
포크
9

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
share-extension
description
Share extension with NSExtensionActivationRule filtering, SLComposeServiceViewController handling, App Group data sharing, and shared content processing for URLs, text, and images. Use when adding share sheet integration to an iOS app.
tags
swiftui, ios, extensions
platforms
ios
# Share Extension ## Overview The share extension receives content (URLs, text, images) from other apps via the system share sheet. It runs as a separate process with limited memory and no direct access to the main app's data unless App Groups are configured. ## Setup Requires a separate extension target configured as `kind: "share"` in the plan extensions array. ## Principal View Controller Implement `SLComposeServiceViewController` to handle shared content: ```swift import Social import UniformTypeIdentifiers class ShareViewController: SLComposeServiceViewController { override func isContentValid() -> Bool { return contentText.count > 0 } override func didSelectPost() { guard let item = extensionContext?.inputItems.first as? NSExtensionItem, let provider = item.attachments?.first else { extensionContext?.completeRequest(returningItems: [], completionHandler: nil) return } if provider.hasItemConformingToTypeIdentifier("public.url") { provider.loadItem(forTypeIdentifier: "public.url") { [weak self] url, _ in // Process the shared URL self?.extensionContext?.completeRequest(returningItems: [], completionHandler: nil) } } } override func configurationItems() -> [Any]! { return [] // Return SLComposeSheetConfigurationItem array for extra UI rows } } ``` ## Info.plist Configuration Set these keys in the extension target's Info.plist (via XcodeGen): ``` NSExtensionPrincipalClass: $(PRODUCT_MODULE_NAME).ShareViewController NSExtensionActivationRule: NSExtensionActivationSupportsWebURLWithMaxCount: 1 NSExtensionActivationSupportsText: true ``` ## Data Sharing via App Groups Use the App Group entitlement to share data between the main app and the extension. Both targets must belong to the same App Group to access shared `UserDefaults` or a shared container directory.
GitHub에서 보기