Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

📦 DocumentBrowser-iOS

swift v5.2 platform iOS v11 swift package manager compatible carthage compatible test coverage 100%

DocumentBrowser is a convenient wrapper for UIDocumentBrowserViewController for use in document-based iOS applications.

🛠 Tech stack

🧰 Installation

  • Minimum deployment target: iOS 11

Swift Package Manager / Xcode

DocumentBrowser is compatible with Swift Package Manager. You can add it as a dependency to your Xcode project or swift package.


You can use Carthage to build DocumentBrowser framework. Follow Carthage documentation for instructions.

📝 Usage

DocumentBrowsing protocol is the main interface of the package. It provides an instance of a document browser view controller that you can present in your app. Is also allows to open document located at the provided URL, which is the feature you want to use when implementing deep-links.

public protocol DocumentBrowsing {
  var viewController: UIViewController { get }
  func openDocument(at url: URL)

To create an instance of DocumentBrowser, which implements DocumentBrowsing protocol:

let browser: DocumentBrowsing = DocumentBrowser(
  viewControllerFactory: /* DocumentBrowserViewControllerCreating */,
  documentInitializer: /* DocumentInitializing */,
  documentCreator: /* DocumentCreating */,
  documentPresenter: /* DocumentPresenting */


🧩 DocumentBrowserViewControllerCreating

public protocol DocumentBrowserViewControllerCreating {
  func createViewController() -> UIDocumentBrowserViewController

Document browser view controller factory. You can implement it by conforming to DocumentBrowserViewControllerCreating protocol or use DocumentBrowserViewControllerFactory implementation for your convenience.

🧩 DocumentInitializing

public protocol DocumentInitializing {
  func initializeDocument(with url: URL) -> UIDocument

Document object factory you can implement by conforming to DocumentInitializing protocol. The factory should return an instance of the UIDocument subclass.

🧩 DocumentCreating

public protocol DocumentCreating {
  func createDocument(importHandler: @escaping (URL?, UIDocumentBrowserViewController.ImportMode) -> Void)

Factory for creating new documents. It's used when the user requests a new document creation from the browser. You can implement the logic by confirming to DocumentCreating protocol, or use one of the included implementations:

  • EmptyDocumentCreator - Creates a new document file in a temporary directory and then imports (moves) it into the desired location.
  • TemplateDocumentCreator - Creates a new document file by copying given template file into the desired location.

🧩 DocumentPresenting

public protocol DocumentPresenting {
  func presentDocument(_ document: UIDocument, from presenting: UIViewController)

Document user interface presenter. You should implement the logic of presenting UIDocument in your app by conforming to DocumentPresenting protocol. Document presenter is used when opening existing or creating a new document from the browser. The document parameter passed to presentDocument function is an instance of UIDocument subclass, returned by document initializer (see: DocumentInitializing). The view controller parameter is the browser view controller instance that was used to open the document.

🛠 Development

You can open Package.swift in Xcode:

open Package.swift

Xcode build scheme is set up for building the library and running unit tests suite.

📄 License

Copyright © 2020 Dariusz Rybicki Darrarski

License: GNU GPLv3


Convenient wrapper for UIDocumentBrowserViewController for use in document-based iOS applications.








No packages published