Skip to main content
OpenCV provides native iOS support through frameworks that can be integrated into Xcode projects with both Objective-C and Swift.

Quick Start

Get OpenCV running on iOS in minutes:
1

Prerequisites

Install required tools:
2

Clone OpenCV

3

Build Framework

This builds for iOS devices (arm64) and simulators (x86_64, arm64). Takes 15-30 minutes.
4

Find Output

The framework will be at:

System Requirements

  • macOS: 10.15 (Catalina) or later
  • Xcode: 12.2 or later
  • CMake: 3.19.0 or later (3.17+ for older Xcode)
  • Python: 3.6 or later
  • iOS Deployment Target: 9.0 or later (default)
Building iOS frameworks is only supported on macOS with Xcode installed.

Supported Architectures

OpenCV iOS framework includes:
PlatformArchitecturesUsage
iOS Devicearm64, armv7, armv7sPhysical iPhones and iPads
iOS Simulatorx86_64, arm64Testing on Mac (Intel and Apple Silicon)
By default, build_framework.py builds for arm64 (devices) and x86_64 + arm64 (simulators). Older armv7/armv7s can be included if needed.

Building OpenCV Framework

Standard Build

The simplest way to build OpenCV for iOS:
Output location: ~/ios/opencv2.framework

Build with opencv_contrib Modules

Include extra modules:

Custom Build Options

Complete Build Command

Build Script Options

Key options for build_framework.py:

Building for Specific iOS Versions

Set minimum deployment target:

Building visionOS Framework

For Apple Vision Pro:

Framework Structure

The built framework contains:
Verify architectures:

Integrating into Xcode Projects

Method 1: Drag and Drop (Quick)

1

Add Framework

  1. Drag opencv2.framework into your Xcode project
  2. Check “Copy items if needed”
  3. Select your target
2

Link Framework

Ensure framework is in Target → General → Frameworks, Libraries, and Embedded ContentSet to “Embed & Sign” for dynamic frameworks or “Do Not Embed” for static.
3

Add System Frameworks

Add required iOS frameworks:
  • Accelerate.framework
  • AVFoundation.framework
  • CoreGraphics.framework
  • CoreMedia.framework
  • CoreVideo.framework
  • UIKit.framework

Method 2: CocoaPods

For released versions:
Then:

Method 3: Swift Package Manager

For projects using SPM:
  1. File → Add Packages
  2. Enter OpenCV repository URL
  3. Select version
Official SPM support may be limited. Check OpenCV repository for latest status.

Using OpenCV in Code

Objective-C

Simple usage:

Objective-C++ Bridge for Swift

Create a wrapper class:

Swift

Use through Objective-C++ wrapper:

Advanced Objective-C++ Integration

Direct Mat usage in .mm files:

Camera Integration

Real-time camera processing:

Core Image Integration

Convert between OpenCV Mat and CIImage:

Performance Optimization

Use Accelerate Framework

OpenCV automatically uses iOS’s Accelerate framework for optimized BLAS/LAPACK operations.

Enable NEON Instructions

Built by default for ARM architectures:

Multi-threading

Troubleshooting

Update CMake:
Xcode 12.2+ requires CMake 3.19.0 or later.
  1. Ensure all required system frameworks are linked
  2. Check framework was built for correct architecture
  3. Verify bitcode settings match between app and framework
  1. Ensure framework is added to project
  2. Check Build Settings → Framework Search Paths
  3. Verify Header Search Paths includes framework
  1. Ensure .mm file is in your target
  2. Add bridging header if needed:
  1. Set in Build Settings → Objective-C Bridging Header

Sample Applications

Explore example apps in the OpenCV repository:
Samples include:
  • HelloWorld - Basic OpenCV integration
  • FaceDetection - Real-time face detection
  • VideoFilters - Video processing effects
  • SquareDetection - Shape detection

App Store Submission

Privacy Permissions

Add to Info.plist:

Bitcode

If using dynamic framework, ensure bitcode settings match:

Framework Size Optimization

Next Steps

Swift Integration

Advanced Swift usage patterns

Camera Processing

Real-time camera applications

Core ML Integration

Combine OpenCV with Core ML

Sample Apps

Explore example projects