SwiftUI: How to build document Scanner using Apple Visionkit?

SwiftUI + Visionkit — iOS 14 Xcode 12

Prafulla Singh
2 min readMar 3, 2021

With Apple’s Visionkit, It is super easy to create a document scanner. In this demo we are going to build MVP in less than 100 line.

In this document scanner, We are going to support following feature:

  1. Scan one or multiple documents
  2. Share the Scanned Document
  3. Delete if Document is not needed

*Complete code at the end

Considering you have already created an empty project.

Step 1: Camera permission

Add NSCameraUsageDescription to info.plist

<key>NSCameraUsageDescription</key>
<string>
your access request message</string>

Step 2:

Create a base UI, With a button using which user can open camera to scan document.

Step 3: present VNDocumentCameraViewController on user tap:

--

--

Prafulla Singh
Prafulla Singh

No responses yet