Developing Share Sheet Extension for iOS

TRUETECH is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
Developing Share Sheet Extension for iOS
Medium
~2-3 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1052
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

Share Sheet Extension Development for iOS

Share Sheet Extension (type NSExtensionPointIdentifier: com.apple.share-services) appears in the system share menu when the user taps "Share" in Safari, Photos, Files, or any other application. This allows you to accept content directly—URL, image, file—without switching between applications.

NSItemProvider — The Heart of Share Extension

Incoming content arrives through extensionContext?.inputItems as an array of NSExtensionItem. Each contains attachments: [NSItemProvider]. You must check hasItemConformingToTypeIdentifier for the needed UTI and load data through loadItem(forTypeIdentifier:options:completionHandler:).

This is asynchronous. And this is where problems start: developers often load data in viewDidLoad() without waiting for completion and try to use the result synchronously. The extension crashes or shows empty data.

Correct approach for loading a URL from Safari:

guard let item = extensionContext?.inputItems.first as? NSExtensionItem,
      let provider = item.attachments?.first,
      provider.hasItemConformingToTypeIdentifier(UTType.url.identifier) else { return }

provider.loadItem(forTypeIdentifier: UTType.url.identifier) { [weak self] url, error in
    DispatchQueue.main.async {
        self?.receivedURL = url as? URL
        self?.updateUI()
    }
}

Supporting multiple UTIs. The user may select multiple files. NSExtensionItem may contain multiple attachments. Iterate through all, check each via hasItemConformingToTypeIdentifier. Don't forget about kUTTypeFileURL vs kUTTypeURL—these are different types.

Info.plist: NSExtensionActivationRule

This rule determines when your extension appears in the share menu. Poor configuration means the extension appears everywhere unwanted and annoys users.

Basic rule via NSExtensionActivationRule dictionary:

<key>NSExtensionActivationSupportsWebURLWithMaxCount</key><integer>1</integer>
<key>NSExtensionActivationSupportsImageWithMaxCount</key><integer>5</integer>

For complex logic, use an NSPredicate string in NSExtensionActivationRule. For example, to show only for PDF files: SUBQUERY(extensionItems, $item, SUBQUERY($item.attachments, $att, $att.registeredTypeIdentifiers UTI-CONFORMS-TO "com.adobe.pdf").@count >= 1).@count >= 1.

App Group and Data Transfer to the Main Application

Share Extension lives in a separate process. Data from the extension doesn't reach the main application automatically.

Scheme: the extension saves data to App Group container (UserDefaults(suiteName:) or file in containerURL), the main application reads from the same place on next launch. For immediate processing—open the main application via extensionContext?.open(URL(string: "yourapp://share-received")!). But this closes Share Sheet and switches the user—not always desirable.

From iOS 16, you can use SwiftUI in Share Extension through ShareViewController based on UIHostingController. However, UIHostingController in Extension behaves differently: doesn't support @Environment(\.dismiss) for closing via extensionContext?.completeRequest(returningItems:). Close only via extensionContext.

Typical Work Structure

Audit incoming data types to accept. Configure NSExtensionActivationRule. Develop extension UI (compact—max one-third of screen). Integrate via App Group. Handle cancellation (didSelectCancel) and completion (didSelectPost).

Timeline

Simple Share Extension (accept URL or image, show form): 2–4 weeks. Extension with complex logic, multiple file types, server synchronization: 4–7 weeks. Cost is calculated after analyzing content types and UI requirements.