Skip to main content
OpenCV provides native support for macOS on both Intel (x86_64) and Apple Silicon (arm64) architectures. Build universal binaries or create XCFrameworks for multi-platform support.

Quick Start

Get OpenCV running on macOS in minutes:
1

Install Xcode Command Line Tools

Xcode 12.2 or later is required. The full Xcode app is recommended but not strictly necessary for basic builds.
2

Install Homebrew (Optional)

3

Install CMake

Via Homebrew:
Or download from cmake.org and install the .dmg package.
4

Clone and Build OpenCV

System Requirements

  • macOS: 10.12 (Sierra) or later
  • Xcode: 12.2 or later
  • CMake: 3.19.0 or later (3.17+ for older Xcode)
  • Python: 3.8 or later (for Python bindings)
macOS 12.3+ does not include Python 2.7. Install Python 3.x from python.org or Homebrew.

Installation Methods

For the latest features and custom configuration:

Building for Apple Silicon

OpenCV supports native Apple Silicon (M1/M2/M3) builds:

Native ARM64 Build

Universal Binary (x86_64 + arm64)

Universal binaries work on both Intel and Apple Silicon Macs, but result in larger file sizes.

Architecture-Specific Optimizations

Building OpenCV Framework

For use in Xcode projects, build OpenCV as a framework:
The script creates:
  • ~/opencv_build/opencv2.framework - The framework
  • ~/opencv_build/build/ - Intermediate build files

Framework Build Options

Building XCFramework

For multi-platform distribution (macOS + iOS + Catalyst):
This builds OpenCV for:
  • macOS: x86_64, arm64
  • iOS: arm64, armv7
  • iOS Simulator: x86_64, arm64
  • Mac Catalyst: x86_64, arm64
The resulting opencv2.xcframework can be used across all Apple platforms.

XCFramework Build Options

Building XCFramework can take 30-60 minutes as it compiles for 8 architectures across 4 platforms. Use --build_only_specified_archs to reduce build time.

Dependencies and Optional Features

Core Dependencies

Optional Dependencies

macOS uses native Cocoa framework by default (no additional dependencies).For Qt-based GUI:
macOS includes OpenCL by default:

CMake Configuration Options

Standard Build

Python-Specific Configuration

Python 2 support has been removed from recent OpenCV versions. Use Python 3.8 or later.

Optimized Build for Apple Silicon

Building with opencv_contrib

Include extra modules from opencv_contrib:

Installation Locations

Default Installation

With sudo make install, files are placed in:

Custom Installation

Using OpenCV in Xcode Projects

In your CMakeLists.txt:
Generate Xcode project:

With OpenCV Framework

  1. Drag opencv2.framework into your Xcode project
  2. Add to Target → Build Phases → Link Binary With Libraries
  3. Include in code:

Verification

Test your installation:
Create test.cpp:
Compile and run:

Performance Optimization

Use Accelerate Framework

macOS’s Accelerate framework provides optimized BLAS/LAPACK:

Enable Multi-threading

Troubleshooting

Check installation path:
Add to PYTHONPATH if needed:
Update CMake:
Xcode 12.2+ requires CMake 3.19.0+
Ensure consistent architecture:
Clean and retry:
Check Xcode and CMake versions meet requirements.

Next Steps

iOS Development

Build OpenCV for iOS devices

Getting Started

Write your first OpenCV application

Python Bindings

Use OpenCV with Python on macOS

XCFramework Guide

Build for all Apple platforms