Skip to content

Restore macOS support: add x64 and arm64 runtime NuGet packages - #1947

Merged
shimat merged 1 commit into
shimat:mainfrom
mathieucarbou:macos
Jun 27, 2026
Merged

shimat merged 1 commit into
shimat:mainfrom
mathieucarbou:macos

Conversation

@mathieucarbou

@mathieucarbou mathieucarbou commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add a complete macOS CI pipeline that builds libOpenCvSharpExtern.dylib for both Intel (x64) and Apple Silicon (arm64) and publishes them as NuGet packages.

macOS builds are now fully on par with Linux and Windows — all OpenCV modules are enabled including FFmpeg, Tesseract, HDF5, and Freetype, all statically linked via vcpkg.

New Packages

Package Platform
OpenCvSharp4.runtime.osx.x64 macOS x64 (Intel)
OpenCvSharp4.runtime.osx.arm64 macOS arm64 (Apple Silicon)

The old OpenCvSharp4.runtime.osx.10.15-x64 package is renamed to OpenCvSharp4.runtime.osx.x64 (dropping the macOS version from the package name, consistent with other platforms).

Installation

dotnet add package OpenCvSharp4
# Intel (x64):
dotnet add package OpenCvSharp4.runtime.osx.x64
# Apple Silicon (arm64):
dotnet add package OpenCvSharp4.runtime.osx.arm64

Files Added

  • .github/workflows/macos.yml — CI workflow with build_x64 (macos-26-intel), build_arm64 (macos-26), test, and nuget jobs. Builds OpenCV from source via vcpkg + CMake/Ninja, then builds OpenCvSharpExtern, runs tests on arm64, and packs both runtime NuGet packages. Includes vcpkg and OpenCV caching with keys that track submodule SHAs and workflow file changes.
  • cmake/triplets/x64-osx-static.cmake and cmake/triplets/arm64-osx-static.cmake — vcpkg triplets for static macOS builds (release-only).
  • nuget/OpenCvSharp4.runtime.osx.arm64.csproj — NuGet packaging for arm64 dylib → runtimes/osx-arm64/native.

Files Modified

  • src/OpenCvSharpExtern/CMakeLists.txt
    • Add /opt/homebrew/lib to APPLE link_directories (Apple Silicon).
    • Pre-resolve Eigen3 (find_package) before OpenCV config on APPLE — OpenCV's static cmake config references Eigen3::Eigen but does not call find_package for it.
    • Remove NOT APPLE guard on Tesseract linking — Tesseract is now linked on macOS too, same as Windows and Linux.
  • src/OpenCvSharpExtern/include_opencv.h — Remove NO_TEXT guard around #include <opencv2/text.hpp>.
  • .github/workflows/publish_nuget.yml — Uncomment and update macOS artifact download; add osx.x64 and osx.arm64 package validation checks.
  • nuget/OpenCvSharp4.runtime.osx.x64.csproj (renamed from osx.10.15-x64) — Update PackageId, target frameworks to netstandard2.0/2.1/net8.0.
  • nuget/README.runtime.md, README.md, docs/docfx/articles/intro.md, nuget/README.managed.md — Document macOS x64 + arm64 packages and installation.
  • .gitignore — Add opencv_artifacts_arm64/ and src/build-arm64/.

macOS Build Details

  • FFmpeg, Tesseract, HDF5, Freetype, and Harfbuzz are installed as static libraries via vcpkg classic mode and merged into the manifest install directory so the vcpkg toolchain finds them.
  • CMAKE_OSX_DEPLOYMENT_TARGET=11.0 for both x64 and arm64 (macOS Big Sur, November 2020 — minimum version that supports Apple Silicon).
  • Homebrew protobuf/abseil are uninstalled before building OpenCV to prevent their C++17 headers from conflicting with OpenCV's bundled C++11 protobuf.
  • Transitive static library dependencies are explicitly listed in CMAKE_SHARED_LINKER_FLAGS: -llzma -lzstd -lsharpyuv -lwebp -lwebpmux -lwebpdemux -lwebpdecoder -ljpeg -lpng16 -ltiff -ltesseract -lleptonica -lgif -lfreetype -lharfbuzz

Verification

Verified locally: arm64 dylib builds and links successfully on Apple Silicon (M-series) with only system framework dependencies. CI builds and tests pass for both x64 and arm64.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds macOS x64 and arm64 build, test, and packaging support; introduces matching vcpkg triplets and runtime NuGet projects; and updates workflow validation, docs, and local build ignores.

Changes

macOS build and packaging

Layer / File(s) Summary
macOS build inputs
cmake/triplets/*-osx-static.cmake, src/OpenCvSharpExtern/..., .gitignore
macOS triplets, Apple linker search paths, NO_TEXT gating, and local build output ignores update the native build setup for Apple targets.
Runtime package projects
nuget/OpenCvSharp4.runtime.osx.x64.csproj, nuget/OpenCvSharp4.runtime.osx.arm64.csproj, nuget/README.runtime.md
The x64 runtime package identity changes to OpenCvSharp4.runtime.osx.x64, a new arm64 runtime package project is added, and the runtime package table lists both macOS packages.
macOS workflow jobs
.github/workflows/macos.yml, .github/workflows/publish_nuget.yml
The macOS workflow adds x64 and arm64 build jobs, arm64 testing, and main-branch packing; the publish workflow downloads the macOS artifact and requires both new runtime packages.
Installation docs
README.md, docs/docfx/articles/intro.md, nuget/README.managed.md
The README and intro article add macOS badges, supported-platform entries, and install commands for the x64 and arm64 runtime packages.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • shimat/opencvsharp#1831: Updates nuget/README.runtime.md and NuGet packaging in the same runtime-package area as this PR.
  • shimat/opencvsharp#1883: Modifies .github/workflows/publish_nuget.yml validation logic in the same workflow that this PR extends.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the main change: restoring macOS support by adding x64 and arm64 runtime NuGet packages.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
nuget/OpenCvSharp4.runtime.osx.x64.csproj (1)

8-8: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚖️ Poor tradeoff

Breaking rename without a compatibility shim.

OpenCvSharp4.runtime.osx.10.15-x64 is being renamed to OpenCvSharp4.runtime.osx.x64. Per nuget/README.runtime.md, the analogous linux-arm rename was kept as a compatibility shim that pulls in the renamed package. Consumers still referencing the old osx.10.15-x64 id will silently stop receiving updates. Consider publishing a meta-package shim or documenting the migration prominently.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@nuget/OpenCvSharp4.runtime.osx.x64.csproj` at line 8, The package ID rename
from OpenCvSharp4.runtime.osx.10.15-x64 to OpenCvSharp4.runtime.osx.x64 needs a
compatibility shim so existing consumers don’t break. Update the runtime package
metadata in the osx x64 csproj and add a meta-package wrapper, similar to the
linux-arm compatibility pattern referenced in nuget/README.runtime.md, so the
old package ID continues to resolve to the new one and receive updates.
.github/workflows/macos.yml (1)

408-419: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Always-beta package version.

BETA: "-beta" is hardcoded, so every package produced from main is suffixed -beta and there is no path to a stable release from this workflow. If a stable release is ever intended from this pipeline, this should be parameterized (e.g. via workflow_dispatch input).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/macos.yml around lines 408 - 419, The macOS packaging step
hardcodes the beta suffix, so the workflow can only produce `-beta` versions and
cannot generate a stable release. Update the version handling in this workflow
so the suffix is parameterized instead of fixed, using the existing
packaging/`dotnet pack` steps for `OpenCvSharp4.runtime.osx.x64` and
`OpenCvSharp4.runtime.osx.arm64`, and wire it to a configurable input or
variable that can switch between beta and stable behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/macos.yml:
- Line 23: The macOS workflow is pinned to a retired runner label, causing the
job to fail before it starts. Update the `runs-on` setting in the `macos.yml`
workflow from the old `macos-13` label to `macos-15-intel` so the Intel dylib
build uses a supported runner. Locate the change in the workflow job that builds
the x86_64 dylib and keep the runner choice aligned with GitHub’s current Intel
macOS support.

---

Nitpick comments:
In @.github/workflows/macos.yml:
- Around line 408-419: The macOS packaging step hardcodes the beta suffix, so
the workflow can only produce `-beta` versions and cannot generate a stable
release. Update the version handling in this workflow so the suffix is
parameterized instead of fixed, using the existing packaging/`dotnet pack` steps
for `OpenCvSharp4.runtime.osx.x64` and `OpenCvSharp4.runtime.osx.arm64`, and
wire it to a configurable input or variable that can switch between beta and
stable behavior.

In `@nuget/OpenCvSharp4.runtime.osx.x64.csproj`:
- Line 8: The package ID rename from OpenCvSharp4.runtime.osx.10.15-x64 to
OpenCvSharp4.runtime.osx.x64 needs a compatibility shim so existing consumers
don’t break. Update the runtime package metadata in the osx x64 csproj and add a
meta-package wrapper, similar to the linux-arm compatibility pattern referenced
in nuget/README.runtime.md, so the old package ID continues to resolve to the
new one and receive updates.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d650895a-100a-4a72-836d-4331d9e20e78

📥 Commits

Reviewing files that changed from the base of the PR and between b1ccbe9 and 018087e.

📒 Files selected for processing (12)
  • .github/workflows/macos.yml
  • .github/workflows/publish_nuget.yml
  • .gitignore
  • README.md
  • cmake/triplets/arm64-osx-static.cmake
  • cmake/triplets/x64-osx-static.cmake
  • docs/docfx/articles/intro.md
  • nuget/OpenCvSharp4.runtime.osx.arm64.csproj
  • nuget/OpenCvSharp4.runtime.osx.x64.csproj
  • nuget/README.runtime.md
  • src/OpenCvSharpExtern/CMakeLists.txt
  • src/OpenCvSharpExtern/include_opencv.h

Comment thread .github/workflows/macos.yml Outdated
@mathieucarbou
mathieucarbou force-pushed the macos branch 3 times, most recently from 236d32f to 60b3a4b Compare June 26, 2026 17:37

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
README.md (1)

211-211: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Add macOS to the native bindings availability statement.

Line 211 states "Currently, native bindings for Windows x64/ARM64, Linux x64/ARM64, and WebAssembly are available." Since this PR restores macOS support with x64 and arm64 packages, macOS should be listed here to keep the documentation accurate.

-Native binding (OpenCvSharpExtern.dll / libOpenCvSharpExtern.so) is required for OpenCvSharp to work. To use OpenCvSharp, you should add both `OpenCvSharp4` and `OpenCvSharp4.runtime.*` packages to your project. Currently, native bindings for Windows x64/ARM64, Linux x64/ARM64, and WebAssembly are available.
+Native binding (OpenCvSharpExtern.dll / libOpenCvSharpExtern.so / libOpenCvSharpExtern.dylib) is required for OpenCvSharp to work. To use OpenCvSharp, you should add both `OpenCvSharp4` and `OpenCvSharp4.runtime.*` packages to your project. Currently, native bindings for Windows x64/ARM64, Linux x64/ARM64, macOS x64/ARM64, and WebAssembly are available.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` at line 211, Add macOS to the native bindings availability
statement in the README text describing OpenCvSharp native bindings. Update the
sentence that currently lists Windows x64/ARM64, Linux x64/ARM64, and
WebAssembly so it also mentions macOS x64/arm64, matching the restored support
and keeping the documentation accurate.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/macos.yml:
- Around line 364-370: The macOS test workflow is writing the TRX file to the
default TestResults location, so the later artifact upload cannot find it.
Update the dotnet test invocation in the macos workflow to explicitly set a
results directory and make the upload-artifact path match that location, using
the existing test-results.trx output from the OpenCvSharp.Tests run.

In `@README.md`:
- Line 3: Update the badge alt text in the README so the platform name uses the
correct casing, changing every “Github” label in that badge line to “GitHub”
including the macOS badge and the existing badges beside it. Locate the markdown
badge definitions in README.md and keep the links unchanged while only
correcting the visible alt text/title wording.
- Around line 95-111: Add the missing macOS installation guidance to
nuget/README.managed.md so it matches the root README and other platform
sections. Update the Quick Start area with a macOS subsection for Intel and
Apple Silicon that shows adding OpenCvSharp4 plus the matching runtime package
(OpenCvSharp4.runtime.osx.x64 or OpenCvSharp4.runtime.osx.arm64), and include
the same Requirements note listing the excluded modules (FFmpeg-based video I/O,
Tesseract OCR, HDF, Freetype). Follow the existing Linux/Ubuntu formatting and
keep the section aligned with the README structure.

---

Outside diff comments:
In `@README.md`:
- Line 211: Add macOS to the native bindings availability statement in the
README text describing OpenCvSharp native bindings. Update the sentence that
currently lists Windows x64/ARM64, Linux x64/ARM64, and WebAssembly so it also
mentions macOS x64/arm64, matching the restored support and keeping the
documentation accurate.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e12f166c-f5a8-40f9-9052-11ca1ca08c86

📥 Commits

Reviewing files that changed from the base of the PR and between 018087e and 29ceb40.

📒 Files selected for processing (12)
  • .github/workflows/macos.yml
  • .github/workflows/publish_nuget.yml
  • .gitignore
  • README.md
  • cmake/triplets/arm64-osx-static.cmake
  • cmake/triplets/x64-osx-static.cmake
  • docs/docfx/articles/intro.md
  • nuget/OpenCvSharp4.runtime.osx.arm64.csproj
  • nuget/OpenCvSharp4.runtime.osx.x64.csproj
  • nuget/README.runtime.md
  • src/OpenCvSharpExtern/CMakeLists.txt
  • src/OpenCvSharpExtern/include_opencv.h
✅ Files skipped from review due to trivial changes (2)
  • .gitignore
  • nuget/README.runtime.md
🚧 Files skipped from review as they are similar to previous changes (8)
  • nuget/OpenCvSharp4.runtime.osx.arm64.csproj
  • cmake/triplets/arm64-osx-static.cmake
  • cmake/triplets/x64-osx-static.cmake
  • src/OpenCvSharpExtern/include_opencv.h
  • src/OpenCvSharpExtern/CMakeLists.txt
  • docs/docfx/articles/intro.md
  • .github/workflows/publish_nuget.yml
  • nuget/OpenCvSharp4.runtime.osx.x64.csproj

Comment thread .github/workflows/macos.yml Outdated
Comment thread README.md

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
README.md (1)

193-212: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Add the new macOS runtime packages to the native bindings table.

The native bindings table is missing the two new macOS packages introduced by this PR. Also update the summary sentence at line 211 to include macOS.

 |**[OpenCvSharp4.runtime.wasm](https://www.nuget.org/packages/OpenCvSharp4.runtime.wasm/)**| Native bindings for WebAssembly |
+|**[OpenCvSharp4.runtime.osx.x64](https://www.nuget.org/packages/OpenCvSharp4.runtime.osx.x64/)**| Native bindings for macOS Intel (x64). FFmpeg, Tesseract, HDF, and Freetype are not included. |
+|**[OpenCvSharp4.runtime.osx.arm64](https://www.nuget.org/packages/OpenCvSharp4.runtime.osx.arm64/)**| Native bindings for macOS Apple Silicon (arm64). FFmpeg, Tesseract, HDF, and Freetype are not included. |
 
 > **Note:** Windows x86 (32-bit) support has been dropped as of the OpenCV 4.13.0 release series.
 > The `OpenCvSharp4.runtime.win` and `OpenCvSharp4.runtime.win.slim` packages now ship **x64-only** native binaries.
 > Users requiring x86 Windows support should stay on the last OpenCV 4.12.x-based packages.
 
-Native binding (OpenCvSharpExtern.dll / libOpenCvSharpExtern.so) is required for OpenCvSharp to work. To use OpenCvSharp, you should add both `OpenCvSharp4` and `OpenCvSharp4.runtime.*` packages to your project. Currently, native bindings for Windows x64/ARM64, Linux x64/ARM64, and WebAssembly are available.
+Native binding (OpenCvSharpExtern.dll / libOpenCvSharpExtern.so / libOpenCvSharpExtern.dylib) is required for OpenCvSharp to work. To use OpenCvSharp, you should add both `OpenCvSharp4` and `OpenCvSharp4.runtime.*` packages to your project. Currently, native bindings for Windows x64/ARM64, Linux x64/ARM64, macOS x64/arm64, and WebAssembly are available.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` around lines 193 - 212, The native bindings section is missing the
new macOS runtime entries, so update the table in README to include the two
macOS packages alongside the existing Windows, Linux, and WASM rows. Also revise
the summary sentence near the end of that section to mention macOS support in
addition to the current platforms.

Source: Coding guidelines

♻️ Duplicate comments (1)
README.md (1)

3-3: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix "Github" to "GitHub" in all badge alt texts.

All five workflow badge alt texts still use "Github" instead of the correct "GitHub" spelling. This was flagged in a previous review and remains unfixed.

- [![Github Actions Windows Status](https://github.com/shimat/opencvsharp/workflows/Windows%20Server%202025/badge.svg)](https://github.com/shimat/opencvsharp/actions)  [![Github Actions Docker Test Status](https://github.com/shimat/opencvsharp/workflows/Docker%20Test/badge.svg)](https://github.com/shimat/opencvsharp/actions)  [![Github Actions manylinux Status](https://github.com/shimat/opencvsharp/workflows/manylinux/badge.svg)](https://github.com/shimat/opencvsharp/actions)  [![Github Actions Wasm Status](https://github.com/shimat/opencvsharp/workflows/Wasm/badge.svg)](https://github.com/shimat/opencvsharp/actions) [![Github Actions macOS Status](https://github.com/shimat/opencvsharp/workflows/macos/badge.svg)](https://github.com/shimat/opencvsharp/actions)
+ [![GitHub Actions Windows Status](https://github.com/shimat/opencvsharp/workflows/Windows%20Server%202025/badge.svg)](https://github.com/shimat/opencvsharp/actions)  [![GitHub Actions Docker Test Status](https://github.com/shimat/opencvsharp/workflows/Docker%20Test/badge.svg)](https://github.com/shimat/opencvsharp/actions)  [![GitHub Actions manylinux Status](https://github.com/shimat/opencvsharp/workflows/manylinux/badge.svg)](https://github.com/shimat/opencvsharp/actions)  [![GitHub Actions Wasm Status](https://github.com/shimat/opencvsharp/workflows/Wasm/badge.svg)](https://github.com/shimat/opencvsharp/actions) [![GitHub Actions macOS Status](https://github.com/shimat/opencvsharp/workflows/macos/badge.svg)](https://github.com/shimat/opencvsharp/actions)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@README.md` at line 3, The badge alt texts in the README still use the
incorrect “Github” spelling; update all workflow badge labels to “GitHub” for
consistency. Locate the markdown badge line in README and change each alt text
string, including the Windows, Docker Test, manylinux, Wasm, and macOS badges,
so they all use the same corrected capitalization.

Source: Linters/SAST tools

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@README.md`:
- Around line 95-111: The macOS installation guidance added in README.md is
missing from the NuGet docs, so update both nuget/README.managed.md and
nuget/README.runtime.md to stay in sync. Add the same step-by-step macOS setup
instructions shown in the root README, including the OpenCvSharp4 package
install and the x64/arm64 runtime package examples, and make sure the existing
macOS package notes in the README.runtime.md section are expanded rather than
duplicated inconsistently.

---

Outside diff comments:
In `@README.md`:
- Around line 193-212: The native bindings section is missing the new macOS
runtime entries, so update the table in README to include the two macOS packages
alongside the existing Windows, Linux, and WASM rows. Also revise the summary
sentence near the end of that section to mention macOS support in addition to
the current platforms.

---

Duplicate comments:
In `@README.md`:
- Line 3: The badge alt texts in the README still use the incorrect “Github”
spelling; update all workflow badge labels to “GitHub” for consistency. Locate
the markdown badge line in README and change each alt text string, including the
Windows, Docker Test, manylinux, Wasm, and macOS badges, so they all use the
same corrected capitalization.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2edb7f69-c57b-4d5a-995b-97d0b5dbdab7

📥 Commits

Reviewing files that changed from the base of the PR and between 29ceb40 and 60b3a4b.

📒 Files selected for processing (12)
  • .github/workflows/macos.yml
  • .github/workflows/publish_nuget.yml
  • .gitignore
  • README.md
  • cmake/triplets/arm64-osx-static.cmake
  • cmake/triplets/x64-osx-static.cmake
  • docs/docfx/articles/intro.md
  • nuget/OpenCvSharp4.runtime.osx.arm64.csproj
  • nuget/OpenCvSharp4.runtime.osx.x64.csproj
  • nuget/README.runtime.md
  • src/OpenCvSharpExtern/CMakeLists.txt
  • src/OpenCvSharpExtern/include_opencv.h
✅ Files skipped from review due to trivial changes (3)
  • nuget/README.runtime.md
  • .gitignore
  • docs/docfx/articles/intro.md
🚧 Files skipped from review as they are similar to previous changes (8)
  • nuget/OpenCvSharp4.runtime.osx.arm64.csproj
  • cmake/triplets/x64-osx-static.cmake
  • nuget/OpenCvSharp4.runtime.osx.x64.csproj
  • cmake/triplets/arm64-osx-static.cmake
  • src/OpenCvSharpExtern/CMakeLists.txt
  • .github/workflows/publish_nuget.yml
  • src/OpenCvSharpExtern/include_opencv.h
  • .github/workflows/macos.yml

Comment thread README.md
@mathieucarbou

Copy link
Copy Markdown
Contributor Author

You can see the workflow running in my fork, at least for the tasks it is able to do under the permissions it has: https://github.com/mathieucarbou/shimat-opencvsharp/actions/workflows/macos.yml

@mathieucarbou
mathieucarbou force-pushed the macos branch 6 times, most recently from e9ff4c1 to 8296428 Compare June 26, 2026 21:35
@mathieucarbou
mathieucarbou marked this pull request as draft June 26, 2026 22:15
@mathieucarbou

Copy link
Copy Markdown
Contributor Author

Converted PR to draft - need to fix this remaining error: https://github.com/mathieucarbou/shimat-opencvsharp/actions/runs/28267030324/job/83756059344#step:11:25

I already got a green build previously by excluding ffmpeg and some others from the linkage, test passed, but I am now trying to keep the features on par with the linux platforms.

@mathieucarbou mathieucarbou mentioned this pull request Jun 26, 2026
Add a complete macOS CI pipeline that builds libOpenCvSharpExtern.dylib
for both Intel (x64) and Apple Silicon (arm64) and publishes them as
NuGet packages. macOS builds are now fully on par with Linux and Windows
— all OpenCV modules are enabled including FFmpeg, Tesseract, HDF5, and
Freetype, all statically linked via vcpkg.

New packages:
  - OpenCvSharp4.runtime.osx.x64    (macOS x64, Intel)
  - OpenCvSharp4.runtime.osx.arm64  (macOS arm64, Apple Silicon)

The old OpenCvSharp4.runtime.osx.10.15-x64 package is renamed to
OpenCvSharp4.runtime.osx.x64 (dropping the macOS version from the
package name, consistent with other platforms).

Files added:
  - .github/workflows/macos.yml
      CI workflow with build_x64 (macos-26-intel), build_arm64 (macos-26),
      test, and nuget jobs. Builds OpenCV from source via vcpkg + CMake/Ninja,
      then builds OpenCvSharpExtern, runs tests on arm64, and packs both
      runtime NuGet packages. Includes vcpkg and OpenCV caching with keys
      that track submodule SHAs and workflow file changes.
  - cmake/triplets/x64-osx-static.cmake
  - cmake/triplets/arm64-osx-static.cmake
      vcpkg triplets for static macOS builds (release-only).
  - nuget/OpenCvSharp4.runtime.osx.arm64.csproj
      NuGet packaging for arm64 dylib → runtimes/osx-arm64/native.

Files modified:
  - src/OpenCvSharpExtern/CMakeLists.txt
      • Add /opt/homebrew/lib to APPLE link_directories (Apple Silicon).
      • Pre-resolve Eigen3 (find_package) before OpenCV config on APPLE
        — OpenCV's static cmake config references Eigen3::Eigen but does
        not call find_package for it.
      • Remove 'NOT APPLE' guard on Tesseract linking — Tesseract is now
        linked on macOS too, same as Windows and Linux.
  - src/OpenCvSharpExtern/include_opencv.h
      • Remove NO_TEXT guard around #include <opencv2/text.hpp>.
  - .github/workflows/publish_nuget.yml
      • Uncomment and update macOS artifact download (macos.yml).
      • Add osx.x64 and osx.arm64 package validation checks.
  - nuget/OpenCvSharp4.runtime.osx.x64.csproj (renamed from osx.10.15-x64)
      • Update PackageId, target frameworks to netstandard2.0/2.1/net8.0.
  - nuget/README.runtime.md, README.md, docs/docfx/articles/intro.md,
    nuget/README.managed.md
      • Document macOS x64 + arm64 packages and installation.
  - .gitignore
      • Add opencv_artifacts_arm64/ and src/build-arm64/.

macOS build details:
  - FFmpeg, Tesseract, HDF5, Freetype, and Harfbuzz are installed as
    static libraries via vcpkg classic mode and merged into the manifest
    install directory so the vcpkg toolchain finds them.
  - CMAKE_OSX_DEPLOYMENT_TARGET=11.0 for both x64 and arm64 (macOS Big Sur,
    November 2020 — minimum version that supports Apple Silicon).
  - Homebrew protobuf/abseil are uninstalled before building OpenCV to
    prevent their C++17 headers from conflicting with OpenCV's bundled
    C++11 protobuf.
  - Transitive static library dependencies are explicitly listed in
    CMAKE_SHARED_LINKER_FLAGS: -llzma -lzstd -lsharpyuv -lwebp -lwebpmux
    -lwebpdemux -lwebpdecoder -ljpeg -lpng16 -ltiff -ltesseract
    -lleptonica -lgif -lfreetype -lharfbuzz

Verified locally: arm64 dylib builds and links successfully on
Apple Silicon (M-series) with only system framework dependencies.
@mathieucarbou
mathieucarbou marked this pull request as ready for review June 26, 2026 23:10
@mathieucarbou

mathieucarbou commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor Author

@shimat : I've put this PR as ready to review now.

The macOS workflow and tests are passing as you can see in my fork, and also in this PR in previous builds: https://github.com/mathieucarbou/shimat-opencvsharp/actions

Also I have just rebased / fixup the commits into one.

shimat added a commit that referenced this pull request Jun 27, 2026
Add macOS x64/arm64 CI and runtime packages (port of #1947 to 5.x)
sajmons pushed a commit to sajmons/CollimationCircles that referenced this pull request Jun 27, 2026
…support (#48)

* Use the right OpenCvSharp4.runtime.osx names

See issue: #46

See PR: shimat/opencvsharp#1947

* Run CI on each pull request and branch

(cherry picked from commit fdbfb24)

* Fix ZWO support
hundong2 pushed a commit to hundong2/opencvsharp that referenced this pull request Jul 4, 2026
Port the macOS support added on main (4.x) in shimat#1947 to the 5.x branch,
adapted for OpenCV 5 and the OpenCvSharp5 package naming:

- .github/workflows/macos.yml: build_x64 (macos-26-intel),
  build_arm64 (macos-26), test (arm64), and nuget jobs. Builds OpenCV
  5.0.0 from source via vcpkg + CMake/Ninja, then OpenCvSharpExtern,
  and packs both runtime NuGet packages. OPENCV_VERSION=5.0.0,
  triggers on push to 5.x.
- cmake/triplets/{x64,arm64}-osx-static.cmake: static macOS vcpkg triplets.
- vcpkg.json: add ffmpeg/hdf5/freetype/harfbuzz/eigen3 for osx.
- src/OpenCvSharpExtern/CMakeLists.txt:
  * add /opt/homebrew/lib to APPLE link_directories (Apple Silicon)
  * pre-resolve Eigen3 and HDF5 before OpenCV config on APPLE
  * link Tesseract on macOS too (drop the NOT APPLE guard)
- nuget: rename OpenCvSharp5.runtime.osx.10.15-x64 ->
  OpenCvSharp5.runtime.osx.x64 and add OpenCvSharp5.runtime.osx.arm64;
  target netstandard2.0/2.1/net8.0.
- .github/workflows/publish_nuget.yml: enable macOS artifact download
  and add osx.x64 / osx.arm64 package validation.
- docs: update package list and supported platforms for macOS arm64.

Note: include_opencv.h needs no change on 5.x (text.hpp is already
included unconditionally). The macOS-5 build specifics (find_package
deps, linker flags) may need iteration against the macOS runners.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@shimat shimat added the enhancement New feature or improvement to OpenCvSharp label Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or improvement to OpenCvSharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants