SwiftBindings.Apple.VisionKit 26.2.14

dotnet add package SwiftBindings.Apple.VisionKit --version 26.2.14
                    
NuGet\Install-Package SwiftBindings.Apple.VisionKit -Version 26.2.14
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SwiftBindings.Apple.VisionKit" Version="26.2.14" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SwiftBindings.Apple.VisionKit" Version="26.2.14" />
                    
Directory.Packages.props
<PackageReference Include="SwiftBindings.Apple.VisionKit" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SwiftBindings.Apple.VisionKit --version 26.2.14
                    
#r "nuget: SwiftBindings.Apple.VisionKit, 26.2.14"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SwiftBindings.Apple.VisionKit@26.2.14
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SwiftBindings.Apple.VisionKit&version=26.2.14
                    
Install as a Cake Addin
#tool nuget:?package=SwiftBindings.Apple.VisionKit&version=26.2.14
                    
Install as a Cake Tool

SwiftBindings.Apple.VisionKit

Native .NET bindings for Apple's VisionKit framework — Live Text image analysis, subject lifting, and the DataScannerViewController camera scanner for barcodes and on-screen text. These are not Objective-C proxy wrappers; they use .NET 10's native Swift interop for direct calls into Swift APIs from C#.

📖 Full usage guide → — Swift→C# naming, the analyzer/analysis lifecycle, the data-scanner delegate flow, and interaction types.

Installation

dotnet add package SwiftBindings.Apple.VisionKit

Requirements

  • .NET 10.0+
  • Target framework: net10.0-ios26.2 (or -maccatalyst26.2 / -macos26.2) or higher. The package is compiled against the 26.2 SDK supplement, so your app's <TargetFramework> platform version must be ≥ 26.2 to restore it — an explicit lower TPV (e.g. net10.0-ios18.0) or a bare net10.0-ios whose installed workload defaults below 26.2 fails restore with NU1202. This is the compile-SDK pin, not your app's deployment minimum.
  • Deployment minimum is separate — set your app's real minimum OS with <SupportedOSPlatformVersion> (independent of the TFM above). VisionKit's members carry generated [SupportedOSPlatform] attributes (ImageAnalyzer needs iOS 16 / macOS 13 / Mac Catalyst 17, DataScannerViewController iOS 16), and the C# compiler flags a call that isn't valid for your target.
  • macOS host for development

Usage

Analyze an image for text and machine-readable codes (iOS / Mac Catalyst)

using VisionKit;

using var analyzer = new ImageAnalyzer();
using var configuration = new ImageAnalyzer.Configuration(
    ImageAnalyzer.AnalysisTypes.Text | ImageAnalyzer.AnalysisTypes.MachineReadableCode);
configuration.Locales = new[] { "en-US" };

using var analysis = await analyzer.AnalyzeAsync(image, configuration);
if (analysis.HasResults(ImageAnalyzer.AnalysisTypes.Text))
    Console.WriteLine(analysis.Transcript);

The two-argument form above is the UIImage overload, so it compiles on iOS and Mac Catalyst only. AnalyzeAsync also has overloads for NSImage (macOS), CGImage, CIImage, and an NSUrl pointing at an image file — each of those takes an ImageIO.CGImagePropertyOrientation before the configuration (the second UIImage overload takes a UIKit.UIImageOrientation instead):

using ImageIO;

using var analysis = await analyzer.AnalyzeAsync(cgImage, CGImagePropertyOrientation.Up, configuration);

Each maps to a Swift async throws method, so a framework-side failure surfaces as a faulted Task.

Attach Live Text to an image view (iOS / Mac Catalyst)

using VisionKit;

var interaction = new ImageAnalysisInteraction
{
    Analysis = analysis,
    PreferredInteractionTypes = ImageAnalysisInteraction.InteractionTypes.Automatic,
};

// `subjects` is an async accessor in Swift; the binding surfaces it as a Get…Async method.
var subjects = await interaction.GetSubjectsAsync();

On macOS the equivalent type is ImageAnalysisOverlayView, an NSView subclass you add to a view hierarchy normally.

ImageAnalysisInteraction is @MainActor-isolated — construct it and touch its members on the UI thread. One caveat on the UIKit side: Swift's UIInteraction conformance is not represented in the generated C#, so the interaction does not implement IUIInteraction and cannot be passed to UIView.AddInteraction directly; see the usage guide for the Objective-C messaging workaround.

Configure the data scanner (iOS)

The DataScannerViewController initializer takes a Swift Set<RecognizedDataType>, and building that set from a populated HashSet marshals each element through Swift's Set.insert. The bindings runtime (0.19.3+) routes that call through a plain-C shim rather than a direct CallConvSwift P/Invoke, because Mono's JIT mis-handles the insert's (Bool, @out) tuple return for struct elements. This package's test suite constructs the controller with a populated set on the iOS Simulator, and the runtime's own test suite exercises the same insert path on a physical device under NativeAOT.

using Vision;
using VisionKit;

using var barcodes = DataScannerViewController.RecognizedDataType.Barcode(
    new[] { VNBarcodeSymbology.Ean13, VNBarcodeSymbology.Code128 });
using var text = DataScannerViewController.RecognizedDataType.Text(new[] { "en-US" });

if (DataScannerViewController.IsSupported && DataScannerViewController.IsAvailable)
{
    using var scanner = new DataScannerViewController(
        recognizedDataTypes: new HashSet<DataScannerViewController.RecognizedDataType> { barcodes, text },
        qualityLevel: DataScannerViewController.QualityLevelKind.Balanced,
        recognizesMultipleItems: true,
        isHighFrameRateTrackingEnabled: true,
        isPinchToZoomEnabled: true,
        isGuidanceEnabled: true,
        isHighlightingEnabled: true);
    scanner.StartScanning();
}

RecognizedDataType.GetBarcode() / GetText() are the unparameterized cases. Results arrive either through IDataScannerViewControllerDelegate (implement it and assign scanner.Delegate, keeping your own strong reference — the bridge holds it weakly) or by enumerating scanner.RecognizedItems, an IAsyncEnumerable<IReadOnlyList<RecognizedItem>>. RecognizedItem maps a Swift payload enum, so you read it through its discriminator:

if (item.Tag == RecognizedItem.CaseTag.Text && item.TryGetText(out var text))
    Console.WriteLine(text.Transcript);
else if (item.TryGetBarcode(out var barcode))
    Console.WriteLine(barcode.PayloadStringValue);

Present and retain the controller (it is a UIViewController) before calling StartScanning, and add an NSCameraUsageDescription string to your app's Info.plist — the scanner uses the camera, and iOS terminates an app that requests camera access without it. DataScannerViewController requires a real camera, so IsSupported is false on the simulator and StartScanning — which maps a Swift throws function — raises a Swift.Runtime.SwiftException there; catch it if you run on both.

Platform surface

The Swift interface differs per platform, so the generated surface does too:

TFM What binds
net10.0-ios26.2 Full surface — ImageAnalyzer, ImageAnalysis, ImageAnalysisInteraction, DataScannerViewController + RecognizedItem
net10.0-maccatalyst26.2 ImageAnalyzer, ImageAnalysis, ImageAnalysisInteraction (no DataScannerViewController — Apple does not vend it on Mac Catalyst)
net10.0-macos26.2 ImageAnalyzer, ImageAnalysis, ImageAnalysisOverlayView (AppKit equivalent of the interaction)

VNDocumentCameraViewController is an Objective-C class, not part of the Swift module this package binds; use the existing .NET VisionKit platform bindings for it.

Documentation

How It Works

These bindings are auto-generated by Swift Dotnet Bindings using .NET 10's native Swift interop via the SwiftBindings SDK.

License

The bindings are MIT licensed. VisionKit is part of the Apple SDK; refer to Apple's licensing for the underlying framework.

Product Compatible and additional computed target framework versions.
.NET net10.0-ios26.2 is compatible.  net10.0-maccatalyst26.2 is compatible.  net10.0-macos26.2 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
26.2.14 94 9/5/2026
26.2.13 97 9/2/2026