◉RORK LABJP
●SUBDOMAIN — Rork can now connect your web app to a subdomain only, leaving your root domain and www untouched (12/1)●UPDATES — expo-updates 58.0.23 fixes Android release builds embedding a stale runtime version●FLASH END — Intro pricing for Gemini Flash models ends 12/31, 29 days from now. Time to recheck AI feature costs●HMR — Some report the dev server picking up another server's bundle and then exiting●FIRST VIEW — Map the first screen for a normal launch, a notification, and a link, and back navigation stops surprising you●CARBON — Gemini 4 Carbon and Argon are now at standard rates: $4.00 input, $20.00 output per 1M tokens●SUBDOMAIN — Rork can now connect your web app to a subdomain only, leaving your root domain and www untouched (12/1)●UPDATES — expo-updates 58.0.23 fixes Android release builds embedding a stale runtime version●FLASH END — Intro pricing for Gemini Flash models ends 12/31, 29 days from now. Time to recheck AI feature costs●HMR — Some report the dev server picking up another server's bundle and then exiting●FIRST VIEW — Map the first screen for a normal launch, a notification, and a link, and back navigation stops surprising you●CARBON — Gemini 4 Carbon and Argon are now at standard rates: $4.00 input, $20.00 output per 1M tokens
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 Max236VisionKitSwiftUI66DataScanneriOS118App 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-26
Linking.canOpenURL Keeps Returning false on iOS Only — Declaring LSApplicationQueriesSchemes, and the 25-Entry Cap Coming With iOS 27
When Linking.canOpenURL returns false on iOS no matter what is installed, the cause is usually a missing Info.plist declaration. Here is how to fix it in Expo's app.json, what Android needs instead, and how to prepare for the 25-entry limit for apps linked on iOS 27.
◇ 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.