229 docmanager 03 d mu - apple inc. · pdf filenew files app cloud storage—file provider...

206
#WWDC17 © 2017 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. Pau Sastre Miguel, Software Engineer Raffael Hannemann, Software Engineer Maxime Uzan, Software Engineer Building Great Document-based Apps Session 229 App Frameworks

Upload: vodieu

Post on 05-Feb-2018

249 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

#WWDC17

© 2017 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

Pau Sastre Miguel, Software Engineer Raffael Hannemann, Software Engineer Maxime Uzan, Software Engineer

•Building Great Document-based Apps • Session 229

App Frameworks

Page 2: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File
Page 3: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

New Files App Cloud Storage—File provider

File provider extension for external cloud storage

Accessible from the Locations view

File Provider Enhancements Grand Ballroom A Friday 11:00AM

Page 4: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

New Files App iCloud Drive

File provider based

Shows files within the applicationcloud container

Page 5: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Local storage

New Files App On my iPad/iPhone

Page 6: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Local storage

Shows files inside the application container’s Documents folder

New Files App On my iPad/iPhone

Page 7: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Local storage

Shows files inside the application container’s Documents folder

Configure the Info.plist in one of the following ways

New Files App On my iPad/iPhone

Page 8: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Local storage

Shows files inside the application container’s Documents folder

Configure the Info.plist in one of the following ways UISupportsDocumentBrowser

New Files App On my iPad/iPhone

Page 9: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Local storage

Shows files inside the application container’s Documents folder

Configure the Info.plist in one of the following ways UISupportsDocumentBrowserUIFileSharingEnabled + LSSupportsOpeningDocumentsInPlace

New Files App On my iPad/iPhone

Page 10: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Keep the content clean

New Files App On my iPad/iPhone

Page 11: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Keep the content clean

Content is not synced

New Files App On my iPad/iPhone

Page 12: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Keep the content clean

Content is not synced

Included in iCloud Backup

New Files App On my iPad/iPhone

Page 13: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

New Files App Recents

Documents recently• Opened• Imported• Modified

Page 14: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

New Files App Recents

Documents recently• Opened• Imported• Modified

Documents organized by tags

Page 15: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

New Files App Recents

Documents recently• Opened• Imported• Modified

Documents organized by tags

Documents shared with others

Page 16: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

New Files App Tags

New tagging UI

Page 17: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

New Files App Tags

New tagging UI

File provider support

Page 18: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

New Files App Tags

New tagging UI

File provider support

Synced across iOS and macOS

Page 19: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

New Files App Recents Popover

Access recent documents for any app

Page 20: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

New Files App Recents Popover

Access recent documents for any app

Drag and Drop

Page 21: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

What about your app?

Page 22: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Developer Requests

Page 23: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Developer Requests

Unified UI for file browsing

Page 24: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Developer Requests

Unified UI for file browsing

Access files from other app

Page 25: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Developer Requests

Unified UI for file browsing

Access files from other app

Seamless access to other cloud providers

Page 26: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Developer Requests

Unified UI for file browsing

Access files from other app

Seamless access to other cloud providers

Deep integration of custom document types

Page 27: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•Document Browser API •Thumbnail Extension •Quick Look Preview Extension

Page 28: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•Document Browser API •Thumbnail Extension •Quick Look Preview Extension

Page 29: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Document Browser API

UIDocumentBrowserViewController

NEW

Page 30: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Document Browser API

UIDocumentBrowserViewController

New Xcode template

NEW

Page 31: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Document Browser API

UIDocumentBrowserViewController

New Xcode template

Improvements on UIDocumentPickerViewController

NEW

Page 32: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

UIDocumentBrowserViewController

Same feature set as Files

NEW

Page 33: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

UIDocumentBrowserViewController

Same feature set as Files

Integration with other cloud storage providers

NEW

Page 34: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

UIDocumentBrowserViewController

Same feature set as Files

Integration with other cloud storage providers

Customizable appearance

NEW

Page 35: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

UIDocumentBrowserViewController

Same feature set as Files

Integration with other cloud storage providers

Customizable appearance

Recents popover

NEW

Page 36: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Automatic Spotlight file indexing for metadata

You still need to use CoreSpotlight to index the content

De-duplication via the CSSearchableItem contentURL

UIDocumentBrowserViewController Spotlight support

NEW

What’s New in Core Spotlight for iOS and macOS Grand Ballroom B Thursday 4:10PM

Page 37: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

UIDocumentBrowserViewController Privacy model

Can only access files within its container

Page 38: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

UIDocumentBrowserViewController Privacy model

Can only access files within its container

Can import or create new files in the default save location

Page 39: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

UIDocumentBrowserViewController Privacy model

Can only access files within its container

Can import or create new files in the default save location

Your app can gain access to documents via user interaction • Documents in other application containers • Documents stored in any cloud provider

Page 40: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

UIDocumentPickerViewController New look and feel

NEW

Page 41: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

UIDocumentPickerViewController Picking files

NEW

picker.allowsMultipleSelection = true

Page 42: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

UIDocumentPickerViewController Picking files

NEW

picker.allowsMultipleSelection = true

public func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL)

Page 43: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

UIDocumentPickerViewController Picking files

NEW

picker.allowsMultipleSelection = true

public func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentAt url: URL)

public func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL])

Page 44: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•UIDocumentMenuViewController

Page 45: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•UIDocumentBrowserViewController •Getting Started

NEW

Page 46: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Getting started Info.plist

UISupportsDocumentBrowser

Page 47: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Getting started Info.plist

UISupportsDocumentBrowser

Declare the supported content types

Page 48: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Getting started UIDocumentBrowserViewController

Root View Controller

Page 49: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Appearance

Page 50: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Appearance

browserController.browserInterfaceStyle = .dark // .white or .light browserController.view.tintColor = .orange // any UIColor

Page 51: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•Opening Documents

Page 52: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

User taps on a document

•Opening Documents

Page 53: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

User taps on a documentFetch/Download the

document

•Opening Documents

Page 54: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

User taps on a documentFetch/Download the

document

Extend access

•Opening Documents

Page 55: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Did pick documents

User taps on a documentFetch/Download the

document

Extend access

•Opening Documents

Page 56: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Did pick documents

User taps on a documentFetch/Download the

document

Extend access

Load and present

•Opening Documents

Page 57: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Persistent access to the file URL

Opening Documents

Page 58: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Persistent access to the file URL

Use Bookmarks for state restoration

Opening Documents

Page 59: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Persistent access to the file URL

Use Bookmarks for state restoration

Opening Documents

func documentBrowser(_ controller: UIDocumentBrowserViewController, didPickDocumentURLs documentURLs: [URL]) { present(documentURLs: documentURLs) }

Page 60: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

browserController.allowsPickingMultipleItems = true

Opening Documents

Page 61: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Creating New Documents

Page 62: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Creating New Documents

User requests new document

Page 63: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Creating New Documents

User requests new documentPrepare new document

Page 64: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Creating New Documents

User requests new document

Import Operation

Prepare new document

Import handler

Page 65: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Creating New Documents

User requests new document

Import Operation

Succeed

Prepare new document

Import handler

Page 66: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Creating New Documents

User requests new document

Import Operation

Succeed

Load and present

Prepare new document

Import handler

Page 67: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Creating New Documents

User requests new document

Import Operation

Fail

Prepare new document

Import handler

Page 68: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

func documentBrowser(_ controller: UIDocumentBrowserViewController, didRequestDocumentCreationWithHandler importHandler: @escaping (URL?, UIDocumentBrowserViewController.ImportMode) -> Swift.Void) {

}

Page 69: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

func documentBrowser(_ controller: UIDocumentBrowserViewController, didRequestDocumentCreationWithHandler importHandler: @escaping (URL?, UIDocumentBrowserViewController.ImportMode) -> Swift.Void) { presentTemplateChooser(completion: { (templateURL, canceled) in

}) }

Page 70: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

func documentBrowser(_ controller: UIDocumentBrowserViewController, didRequestDocumentCreationWithHandler importHandler: @escaping (URL?, UIDocumentBrowserViewController.ImportMode) -> Swift.Void) { presentTemplateChooser(completion: { (templateURL, canceled) in if let templateURL = templateURL { importHandler(templateURL, .copy) } else { importHandler(nil, .none) } }) }

Page 71: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

func documentBrowser(_ controller: UIDocumentBrowserViewController, didRequestDocumentCreationWithHandler importHandler: @escaping (URL?, UIDocumentBrowserViewController.ImportMode) -> Swift.Void) { presentTemplateChooser(completion: { (templateURL, canceled) in if let templateURL = templateURL { importHandler(templateURL, .copy) } else { importHandler(nil, .none) } }) } func documentBrowser(_ controller: UIDocumentBrowserViewController, didImportDocumentAt sourceURL: URL, toDestinationURL destinationURL: URL) { present(documentURL: destinationURL) }

Page 72: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

func documentBrowser(_ controller: UIDocumentBrowserViewController, didRequestDocumentCreationWithHandler importHandler: @escaping (URL?, UIDocumentBrowserViewController.ImportMode) -> Swift.Void) { presentTemplateChooser(completion: { (templateURL, canceled) in if let templateURL = templateURL { importHandler(templateURL, .copy) } else { importHandler(nil, .none) } }) } func documentBrowser(_ controller: UIDocumentBrowserViewController, didImportDocumentAt sourceURL: URL, toDestinationURL destinationURL: URL) { present(documentURL: destinationURL) } func documentBrowser(_ controller: UIDocumentBrowserViewController, failedToImportDocumentAt documentURL: URL, error: Error?) { presentError(error) }

Page 73: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

UIDocument

NSFileCoordinator

NSFilePresenter

Security-scoped

Operating with Documents

Building Document Based Apps WWDC 2015

Page 74: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

UIDocument

NSFileCoordinator

NSFilePresenter

Security-scoped

Autosave

Operating with Documents

Building Document Based Apps WWDC 2015

Page 75: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•Demo

Raffael Hannemann

Page 76: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File
Page 77: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File
Page 78: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Demo

Page 79: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Demo

Configure the project

Page 80: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Demo

Configure the project

Create new documents

Page 81: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Demo

Configure the project

Create new documents

Open documents

Page 82: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Demo

Configure the project

Create new documents

Open documents

Customize the style

Page 83: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•UIDocumentBrowserViewController •Providing a great experience

NEW

Page 84: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•Open-in-place •Custom actions •Opening transition

Page 85: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Open files without copying

Open-in-place

Page 86: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Open files without copying

Any application can modify a file in your container

Open-in-place

Page 87: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

func application(_ app: UIApplication, open inputURL: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {

}

Page 88: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

func application(_ app: UIApplication, open inputURL: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool { guard inputURL.isFileURL else { return false } browserController.revealDocument(at: inputURL, importIfNeeded: true) { (revealedDocumentURL, error) in

} return true }

Page 89: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

func application(_ app: UIApplication, open inputURL: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool { guard inputURL.isFileURL else { return false } browserController.revealDocument(at: inputURL, importIfNeeded: true) { (revealedDocumentURL, error) in if let revealedDocumentURL = revealedDocumentURL { present(documentURL: revealedDocumentURL) } else if let error = error { presentError(error) } } return true }

Page 90: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•Custom Actions UIDocumentBrowserAction

Page 91: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•Custom Actions UIDocumentBrowserAction

let action = UIDocumentBrowserAction(identifier: “com.example.particles.export-gif", localizedTitle: “Export as GIF", availability: [.menu, .navigationBar]) { urls in shareGIF(urls) } action.supportedContentTypes = ["com.example.particles"] action.supportsMultipleItems = false

browserController.customActions = [action]

Page 92: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•Custom Actions UIBarButtonItem

Page 93: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•Custom Actions UIBarButtonItem

let settingsButton = UIBarButtonItem(title: "Settings", style: .plain, target: self, action: #selector(showSettings))

browserController.additionalTrailingNavigationBarButtonItems = [settingsButton]

Page 94: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•UIActivityViewController

Page 95: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•UIActivityViewController

Fully control UIActivityViewController

Page 96: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•UIActivityViewController

Fully control UIActivityViewController

Add custom activities

Page 97: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

func documentBrowser(_ controller: UIDocumentBrowserViewController, applicationActivitiesForDocumentURLs documentURLs: [URL]) -> [UIActivity] { return [ExportGIFActivity()]}

Page 98: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

func documentBrowser(_ controller: UIDocumentBrowserViewController, applicationActivitiesForDocumentURLs documentURLs: [URL]) -> [UIActivity] { return [ExportGIFActivity()]} func documentBrowser(_ controller: UIDocumentBrowserViewController, willPresent activityViewController: UIActivityViewController) { activityViewController.excludedActivityTypes = [.print]}

Page 99: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Opening Transition UIDocumentBrowserTransitionController

Page 100: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Loading progress indicator NSProgress

Zoom animation UIViewControllerAnimatedTransitioning

Opening Transition UIDocumentBrowserTransitionController

Page 101: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•Opening Transition UIDocumentBrowserTransitionController

Your Application

TransitionController

Page 102: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•Opening Transition UIDocumentBrowserTransitionController

Your Application

TransitionController

Did pick

Page 103: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•Opening Transition UIDocumentBrowserTransitionController

Your Application

TransitionController

Did pick Load content

Page 104: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•Opening Transition UIDocumentBrowserTransitionController

Update progress

Your Application

TransitionController

Did pick 0% 100%Load content

Page 105: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•Opening Transition UIDocumentBrowserTransitionController

Update progress

Your Application

TransitionController

Did pick 0% 100%Load content Present content

Animate

Page 106: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

var transitionController: UIDocumentBrowserTransitionController? = nil

func documentBrowser(_ controller: UIDocumentBrowserViewController, didPickDocumentURLs documentURLs: [URL]) { if let documentURL = documentURLs.first {

} }

Page 107: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

var transitionController: UIDocumentBrowserTransitionController? = nil

func documentBrowser(_ controller: UIDocumentBrowserViewController, didPickDocumentURLs documentURLs: [URL]) { if let documentURL = documentURLs.first {

let progress = Progress(totalUnitCount: 0) transitionController = controller.transitionController(forDocumentURL: documentURL) transitionController?.loadingProgress = progress

} }

Page 108: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

var transitionController: UIDocumentBrowserTransitionController? = nil

func documentBrowser(_ controller: UIDocumentBrowserViewController, didPickDocumentURLs documentURLs: [URL]) { if let documentURL = documentURLs.first {

let progress = Progress(totalUnitCount: 0) transitionController = controller.transitionController(forDocumentURL: documentURL) transitionController?.loadingProgress = progress loadDocument(documentURL: documentURL, updateProgress: progress) { present(documentURL: documentURL) }) } }

Page 109: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

// UIViewControllerTransitioningDelegate

func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? { return transitionController}

func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { return transitionController}

Page 110: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•Demo

Raffael Hannemann, Software Engineer

Page 111: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Demo

Page 112: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Demo

Open-in-place

Page 113: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Demo

Open-in-place

Custom actions

Page 114: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Demo

Open-in-place

Custom actions

Zoom transition

Page 115: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Maxime Uzan, Software Engineer

•Document Browser API •Thumbnail Extension •Quick Look Preview Extension

NEW

Page 116: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File
Page 117: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File
Page 118: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Through UIDocument

Page 119: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Through UIDocument

Return the thumbnail from your subclass of UIDocument

Page 120: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Through UIDocument

Return the thumbnail from your subclass of UIDocument

Only for files created by your application

Page 121: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Through UIDocument

Return the thumbnail from your subclass of UIDocument

Only for files created by your application

Good performance, file is already loaded when setting the thumbnail

Page 122: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Through UIDocument

override func fileAttributesToWrite(to url: URL, for saveOperation: UIDocumentSaveOperation) throws -> [AnyHashable : Any] {

let thumbnail = thumbnailForDocument(at: url) return [ URLResourceKey.hasHiddenExtensionKey: true, URLResourceKey.thumbnailDictionaryKey: [ URLThumbnailDictionaryItem.NSThumbnail1024x1024SizeKey: thumbnail ] ] }

Page 123: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Thumbnail Extension

Page 124: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Thumbnail Extension

System-wide

Page 125: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Thumbnail Extension

System-wide

Works with all cloud vendors

Page 126: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Thumbnail Extension

System-wide

Works with all cloud vendors

Part of the QuickLook framework

Page 127: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Thumbnail Extension—how it works

Page 128: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Thumbnail Extension—how it works

Requests thumbnail

Page 129: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Thumbnail Extension—how it works

Finds your extensionRequests thumbnail

Page 130: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Thumbnail Extension—how it works

Finds your extension

Forwards thumbnail request

Requests thumbnail

Page 131: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Thumbnail Extension—how it works

Finds your extension

Forwards thumbnail request

Requests thumbnail

Generates thumbnail

Page 132: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Thumbnail Extension—how it works

Finds your extension

Forwards thumbnail request

Requests thumbnail

Generates thumbnail

Returns thumbnail

Page 133: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Thumbnail Extension—how it works

Finds your extension

Forwards thumbnail request

Requests thumbnail

Generates thumbnail

Returns thumbnailForwards thumbnail

Page 134: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Thumbnail Extension—how it works

Finds your extension

Forwards thumbnail request

Displays thumbnail

Requests thumbnail

Generates thumbnail

Returns thumbnailForwards thumbnail

Page 135: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Thumbnail Extension Getting started—Xcode template

Page 136: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Thumbnail Extension Getting started—Info.plist

Page 137: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Thumbnail Extension Getting started—Info.plist

Add all supported UTIs to the QLSupportedContentTypes array

Page 138: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Thumbnail Extension Getting started—Info.plist

Add all supported UTIs to the QLSupportedContentTypes array• You can only provide thumbnails for UTIs you own and export

Page 139: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Thumbnail Extension Getting started—Info.plist

Add all supported UTIs to the QLSupportedContentTypes array• You can only provide thumbnails for UTIs you own and export • iOS will check for strict UTI equality, not conformance

Page 140: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Drawing thumbnails

Page 141: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

QLFileThumbnailRequest

maximumSizefileURL scale

Providing Thumbnails Drawing thumbnails

Page 142: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Drawing thumbnails

QLThumbnailReply

Drawing Block

contextSize

QLFileThumbnailRequest

maximumSizefileURL scale

Page 143: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Drawing thumbnails

CGContext

maximumSize.width

max

imum

Size

.hei

ght

QLThumbnailReply

Drawing Block

contextSize

QLFileThumbnailRequest

maximumSizefileURL scale

Page 144: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Drawing thumbnails

CGContext

maximumSize.width

max

imum

Size

.hei

ght

QLThumbnailReply

Drawing Block

contextSize

QLFileThumbnailRequest

maximumSizefileURL scale

Page 145: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Drawing thumbnails

CGContext

maximumSize.width

max

imum

Size

.hei

ght

maximumSize.width

QLThumbnailReply

Drawing Block

contextSize

QLFileThumbnailRequest

maximumSizefileURL scale

Page 146: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

cont

extS

ize.

heig

ht

Providing Thumbnails Drawing thumbnails

contextSize.width

CGContext

QLThumbnailReply

Drawing Block

contextSize

QLFileThumbnailRequest

maximumSizefileURL scale

Page 147: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Drawing thumbnails

CGContext

QLThumbnailReply

Drawing Block

contextSize

QLFileThumbnailRequest

maximumSizefileURL scale

Page 148: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

QLThumbnailReply

Drawing Block

contextSize

QLFileThumbnailRequest

maximumSizefileURL scale

Providing Thumbnails Drawing thumbnails

CGContext

Page 149: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

QLThumbnailReply

Drawing Block

contextSize

QLFileThumbnailRequest

maximumSizefileURL scale

CGContext

Providing Thumbnails Drawing thumbnails

Page 150: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Providing Thumbnails Image file URL

Page 151: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

QLThumbnailReply

Providing Thumbnails Image file URL

imageFileURL

QLFileThumbnailRequest

maximumSizefileURL scale

Page 152: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

override func provideThumbnail(for request: QLFileThumbnailRequest, _ handler: @escaping (QLThumbnailReply?, Error?) -> Void) { let fileURL = request.fileURL let maximumSize = request.maximumSize let scale = request.scale let contextSize = contextSizeForFile(at: fileURL, maximumSize: maximumSize, scale: scale) let drawingBlock: (CGContext) -> Bool = { context in let success = self.drawThumbnailForFile(at: fileURL, contextSize: contextSize, context: context) return success } let reply = QLThumbnailReply(contextSize: contextSize, drawing: drawingBlock) handler(reply, nil) }

Page 153: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

override func provideThumbnail(for request: QLFileThumbnailRequest, _ handler: @escaping (QLThumbnailReply?, Error?) -> Void) { let fileURL = request.fileURL let maximumSize = request.maximumSize let scale = request.scale let contextSize = contextSizeForFile(at: fileURL, maximumSize: maximumSize, scale: scale) let drawingBlock: (CGContext) -> Bool = { context in let success = self.drawThumbnailForFile(at: fileURL, contextSize: contextSize, context: context) return success } let reply = QLThumbnailReply(contextSize: contextSize, drawing: drawingBlock) handler(reply, nil) }

Page 154: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

override func provideThumbnail(for request: QLFileThumbnailRequest, _ handler: @escaping (QLThumbnailReply?, Error?) -> Void) { let fileURL = request.fileURL let maximumSize = request.maximumSize let scale = request.scale let contextSize = contextSizeForFile(at: fileURL, maximumSize: maximumSize, scale: scale) let drawingBlock: (CGContext) -> Bool = { context in let success = self.drawThumbnailForFile(at: fileURL, contextSize: contextSize, context: context) return success } let reply = QLThumbnailReply(contextSize: contextSize, drawing: drawingBlock) handler(reply, nil) }

Page 155: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

override func provideThumbnail(for request: QLFileThumbnailRequest, _ handler: @escaping (QLThumbnailReply?, Error?) -> Void) { let fileURL = request.fileURL let maximumSize = request.maximumSize let scale = request.scale let contextSize = contextSizeForFile(at: fileURL, maximumSize: maximumSize, scale: scale) let drawingBlock: (CGContext) -> Bool = { context in let success = self.drawThumbnailForFile(at: fileURL, contextSize: contextSize, context: context) return success } let reply = QLThumbnailReply(contextSize: contextSize, drawing: drawingBlock) handler(reply, nil) }

Page 156: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

override func provideThumbnail(for request: QLFileThumbnailRequest, _ handler: @escaping (QLThumbnailReply?, Error?) -> Void) { let fileURL = request.fileURL let maximumSize = request.maximumSize let scale = request.scale let contextSize = contextSizeForFile(at: fileURL, maximumSize: maximumSize, scale: scale) let drawingBlock: (CGContext) -> Bool = { context in let success = self.drawThumbnailForFile(at: fileURL, contextSize: contextSize, context: context) return success } let reply = QLThumbnailReply(contextSize: contextSize, drawing: drawingBlock) handler(reply, nil) }

Page 157: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Thumbnail Extension Image file URL

Page 158: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Thumbnail Extension Image file URL

override func provideThumbnail(for request: QLFileThumbnailRequest, _ handler: @escaping (QLThumbnailReply?, Error?) -> Void) { if let imageFileURL = Bundle.main.url(forResource: "image", withExtension: "jpg") { handler(QLThumbnailReply(imageFileURL: imageFileURL), nil) } else { handler(nil, nil) } }

Page 159: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Thumbnail Extension Testing

Page 160: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•Document Browser API •Thumbnail Extension •Quick Look Preview Extension

NEW

Page 161: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File
Page 162: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File
Page 163: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Providing system-wide Quick Look previews

Page 164: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Providing system-wide Quick Look previews

System-wide

Page 165: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Providing system-wide Quick Look previews

System-wide• Applications using Quick Look

Page 166: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Providing system-wide Quick Look previews

System-wide• Applications using Quick Look• Spotlight when peeking on results

Page 167: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Providing system-wide Quick Look previews

System-wide• Applications using Quick Look• Spotlight when peeking on results

Full Quick Look experience

Page 168: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Providing system-wide Quick Look previews

System-wide• Applications using Quick Look• Spotlight when peeking on results

Full Quick Look experience• Previewed in QLPreviewController

Page 169: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Providing system-wide Quick Look previews

System-wide• Applications using Quick Look• Spotlight when peeking on results

Full Quick Look experience• Previewed in QLPreviewController• Loading spinner

Page 170: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Providing system-wide Quick Look previews

System-wide• Applications using Quick Look• Spotlight when peeking on results

Full Quick Look experience• Previewed in QLPreviewController• Loading spinner

Page 171: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Providing system-wide Quick Look previews

Requests preview

System-wide• Applications using Quick Look• Spotlight when peeking on results

Full Quick Look experience• Previewed in QLPreviewController• Loading spinner

Page 172: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Providing system-wide Quick Look previews

Generates preview

Requests preview

System-wide• Applications using Quick Look• Spotlight when peeking on results

Full Quick Look experience• Previewed in QLPreviewController• Loading spinner

Page 173: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Providing system-wide Quick Look previews

Generates preview

Requests preview

(Loading spinner)

System-wide• Applications using Quick Look• Spotlight when peeking on results

Full Quick Look experience• Previewed in QLPreviewController• Loading spinner

Page 174: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Providing system-wide Quick Look previews

Generates preview

Call handler

Requests preview

(Loading spinner)

System-wide• Applications using Quick Look• Spotlight when peeking on results

Full Quick Look experience• Previewed in QLPreviewController• Loading spinner

Page 175: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Providing system-wide Quick Look previews

Generates preview

Call handler

Requests preview

Displays preview

(Loading spinner)

System-wide• Applications using Quick Look• Spotlight when peeking on results

Full Quick Look experience• Previewed in QLPreviewController• Loading spinner

Page 176: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Getting started—Xcode template

Page 177: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Getting started—Info.plist

Page 178: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Getting started—Info.plist

Add all supported UTIs to the QLSupportedContentTypes array

Page 179: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Getting started—Info.plist

Add all supported UTIs to the QLSupportedContentTypes array• You can only provide previews for UTIs you own and export

Page 180: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Getting started—Info.plist

Add all supported UTIs to the QLSupportedContentTypes array• You can only provide previews for UTIs you own and export • iOS will check for UTI equality, not conformance

Page 181: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Getting started—Info.plist

Add all supported UTIs to the QLSupportedContentTypes array• You can only provide previews for UTIs you own and export • iOS will check for UTI equality, not conformance

Set QLSupportsSearchableItems to YES if you want to provide previews for Spotlight items indexed by your application

Page 182: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Providing File previews

Page 183: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Providing File previews

func preparePreviewOfFile(at url: URL, completionHandler handler: @escaping (Error?) -> Void) { // Load the preview and call the completion handler asynchronously when ready. loadPreviewOfFile(at: url, completionHandler: handler)}

Page 184: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Providing Spotlight previews

Page 185: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Providing Spotlight previews

func preparePreviewOfSearchableItem(identifier: String, queryString: String?, completionHandler handler: @escaping (Error?) -> Void) { // Load the preview and call the completion handler asynchronously when ready. loadPreviewOfSearchableItem(identifier: identifier, queryString: queryString, completionHandler: handler)}

Page 186: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Testing

Page 187: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Testing

Any application that uses Quick Look

Spotlight, by peeking on a result

Page 188: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Quick Look Preview Extension Testing

Any application that uses Quick Look

Spotlight, by peeking on a result

Page 189: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Thumbnails and Preview Extensions Performance recommendations

Page 190: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Thumbnails and Preview Extensions Performance recommendations

Be fast!

Page 191: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Thumbnails and Preview Extensions Performance recommendations

Be fast!• Drawing thumbnails should be quick

Page 192: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Thumbnails and Preview Extensions Performance recommendations

Be fast!• Drawing thumbnails should be quick• Users expect to see a preview quickly after opening a file

Page 193: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Thumbnails and Preview Extensions Performance recommendations

Be fast!• Drawing thumbnails should be quick• Users expect to see a preview quickly after opening a file• No background job after calling the completion handler

Page 194: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Thumbnails and Preview Extensions Performance recommendations

Be fast!• Drawing thumbnails should be quick• Users expect to see a preview quickly after opening a file• No background job after calling the completion handler

Memory is limited

Page 195: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Thumbnails and Preview Extensions Performance recommendations

Be fast!• Drawing thumbnails should be quick• Users expect to see a preview quickly after opening a file• No background job after calling the completion handler

Memory is limited• Keep your extension lean—link with bare minimum libraries/frameworks

Page 196: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Thumbnails and Preview Extensions Performance recommendations

Be fast!• Drawing thumbnails should be quick• Users expect to see a preview quickly after opening a file• No background job after calling the completion handler

Memory is limited• Keep your extension lean—link with bare minimum libraries/frameworks• Check for leaks

Page 197: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

•Document Browser API •Thumbnail Extension •Quick Look Preview Extension

Page 198: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Developer Requests

Unified UI for file browsing

Access files from other applications

Seamless access to other Cloud Providers

Deep integration of custom document types

Page 199: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Developer Requests

Unified UI for file browsing

Access files from other applications

Seamless access to other Cloud Providers

Deep integration of custom document types

Page 200: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Developer Requests

Unified UI for file browsing

Access files from other applications

Seamless access to other Cloud Providers

Deep integration of custom document types

Page 201: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Developer Requests

Unified UI for file browsing

Access files from other applications

Seamless access to other Cloud Providers

Deep integration of custom document types

Page 202: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Developer Requests

Unified UI for file browsing

Access files from other applications

Seamless access to other Cloud Providers

Deep integration of custom document types

Page 203: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

More Informationhttps://developer.apple.com/wwdc17/229

Page 204: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Related Sessions

Building Document-based Apps WWDC 2015

Introducing Drag and Drop WWDC 2017

What’s New in Core Spotlight for iOS and macOS Grand Ballroom B Thursday 4:10PM

File Provider Enhancements Grand Ballroom A Friday 11:00AM

Page 205: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File

Labs

Document Browser Lab Technology Lab B Thu 3:10PM-6:00PM

File Providers and Document Browser Lab Technology Lab H Fri 1:00PM-4:00PM

Page 206: 229 DocManager 03 D MU - Apple Inc. · PDF fileNew Files App Cloud Storage—File provider File provider extension for external cloud storage Accessible from the Locations view File