◉RORK LABJP
●GPT-6.1 SOL — Added to Rork's model menu (09-29) with Low, Medium and High effort; included on Pro and Max●SONNET 5.5 — Claude Sonnet 5.5 is selectable: strong at UI design and faster than Sonnet 5 (09-28)●SDK 58 — Beta since 09/15 with no stable date yet; running projects in Expo Go has required login since 09/03●WIDGET — A write-up traces an iOS widget that renders black only in production builds●OBSERVE — EAS Observe now records native crashes too (SDK 57.0.21 or later, 10/07)●NEW — My App Open Ad Only Showed When the App…●GPT-6.1 SOL — Added to Rork's model menu (09-29) with Low, Medium and High effort; included on Pro and Max●SONNET 5.5 — Claude Sonnet 5.5 is selectable: strong at UI design and faster than Sonnet 5 (09-28)●SDK 58 — Beta since 09/15 with no stable date yet; running projects in Expo Go has required login since 09/03●WIDGET — A write-up traces an iOS widget that renders black only in production builds●OBSERVE — EAS Observe now records native crashes too (SDK 57.0.21 or later, 10/07)●NEW — My App Open Ad Only Showed When the App…
Articles/App Dev
◇ App Dev/2026-06-28Advanced

Building a Live Barcode and Text Scanner in Rork Max with VisionKit's DataScanner

Add a live barcode and text scanner to your Rork Max native Swift app using VisionKit's DataScanner. Covers the SwiftUI bridge, availability handling, throttling repeated detections, and on-device verification with working code.

Rork Max236VisionKitSwiftUI66DataScanneriOS116App Development33

✦ Premium Article

When I asked Rork Max to extend a generated native Swift screen with "let me scan a product barcode," the browser live simulator showed an empty frame and the camera never opened. After some digging the answer was simple: VisionKit's DataScannerViewController does not run in the simulator at all. It only starts on a supported physical device. Rork has been smoothing out real-device testing through its Companion app and cloud Mac compilation in 2026, and camera-dependent features like this are exactly the kind you should plan to verify on hardware from the very start.

This walkthrough adds a screen that recognizes barcodes and text live, at the same time, to your Rork Max native Swift code — including the SwiftUI bridge and on-device verification. As an indie developer who has shipped apps to the App Store since 2014, I have learned that camera features trip you up most often on two fronts: permissions and device differences. I will call those out as we go.

Why pick DataScanner over hand-rolled AVFoundation

There are two common ways to read codes from the camera on iOS. The classic route is wiring up AVCaptureSession yourself and pulling barcodes from AVCaptureMetadataOutput. The other is VisionKit's DataScannerViewController, introduced in iOS 16, which bundles the camera preview, subject highlighting, pinch-to-zoom, and guidance UI together.

AspectHand-rolled AVFoundationVisionKit DataScanner
Preview renderingPlace AVCaptureVideoPreviewLayer yourselfBuilt in
Text recognitionCombine with Vision separatelySame API as barcodes, captured together
HighlightingDraw rectangles manuallyStandard via isHighlightingEnabled
Device supportWorks broadly with any cameraA12 Bionic and later (Neural Engine) only
SimulatorSometimes works, limitedUnsupported (real device required)

For cases where you want to read a product code and a model-number string together, DataScanner is dramatically shorter to write. The trade-off is the limited device support and the simulator gap, both of which you need to design around from the beginning. Before I write a line of scanner code, I decide what to show when scanning is not available.

Step 1: Declare the permission and request camera access

First, add NSCameraUsageDescription to Info.plist. You can edit it from the Rork Max project settings too. A specific, purpose-driven string removes one common App Store review rejection reason.

<key>NSCameraUsageDescription</key>
<string>Used to scan product barcodes and model numbers with the camera.</string>

Request access explicitly before showing the screen. DataScannerViewController.isAvailable returns false when the camera is not authorized, so if you check availability without first prompting, you will misclassify a perfectly capable device as "unsupported." That was my first stumble.

import AVFoundation
 
func requestCameraAccess() async -> Bool {
    switch AVCaptureDevice.authorizationStatus(for: .video) {
    case .authorized:
        return true
    case .notDetermined:
        // The dialog appears here on first run. Call this BEFORE checking availability.
        return await AVCaptureDevice.requestAccess(for: .video)
    case .denied, .restricted:
        return false
    @unknown default:
        return false
    }
}
✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦Turn a scanner feature that silently failed in the simulator into one that reliably runs on real devices, with a proper availability gate
✦Get a UIViewControllerRepresentable wrapper that bridges DataScannerViewController into SwiftUI, plus a 1.5-second throttle that stops the same code from firing over and over
✦Assemble a screen that recognizes barcodes and text at the same time, from the permission prompt to the result display
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Rork Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

◇ App Dev2026-04-26
Native iOS Apps with Rork: SwiftUI to TestFlight
New iPhone projects in Rork are generated in Swift and SwiftUI, and Rork Pro carries them all the way to the App Store. How to tell an old Expo project from a new one, costs in credits, the skeleton prompt, device testing, when to drop into Xcode, and TestFlight submission.
◇ App Dev2026-10-15
When adjustsFontSizeToFit Shrinks Just One Row, Suspect the Box Height, Not the String
Only the 10th row of a list drops to 4pt on iOS, though the data and strings are fine. I read the Yoga rounding and font-fit sources, then counted how often the box comes up short in Node.
◈ Getting Started2026-09-08
Whether You Need Rork Max Is Answered by Your Permissions, Not the Price Page
When I cannot decide between standard Rork and Rork Max, I stop reading the price page. Instead I pull every OS capability my app actually asks for out of app.json and Info.plist, then sort them into what Expo covers, what a config plugin covers, and what truly needs native Swift.