macOS with .NET CLI
Use this workflow if you are evaluating Qt Bridge for C# on macOS. macOS does not bundle Qt with the bridge package, so the build must be pointed at a compatible Qt 6 installation.
Requirements
- macOS arm64 (Apple Silicon)
- .NET SDK 8+
- CMake and Ninja available on
PATH, for example from Homebrew - The Xcode Command Line Tools as the C++ toolchain
- A compatible Qt 6 installation
CMake, Ninja, and the C++ toolchain are used by the bridge build behind the scenes; you do not need to write CMake files or C++ code for a template project.
The selected Qt prefix must contain lib/cmake/Qt6/Qt6Config.cmake. The Qt online installer
installs Qt with this layout, for example in ~/Qt/6.11.0/macos.
Every build needs QtDir, including the build that dotnet run starts. Set it as an environment
variable in your shell, for example in your shell profile, so that you do not have to pass it to
every command:
export QtDir=/path/to/qt-prefix
Create a project from templates
Install the templates:
dotnet new install QtGroup.Qt.Bridge.CSharp.Templates
Create a project:
dotnet new qt -n MyQtApp
cd MyQtApp
Build and run the project with QtDir set:
dotnet build
dotnet run
If you do not set QtDir in the environment, pass it to both commands, because dotnet run
builds the project again:
dotnet build -p:QtDir=/path/to/qt-prefix
dotnet run -p:QtDir=/path/to/qt-prefix
For template options such as --Framework and --SampleCode, generated project structure, and QML
item templates, see Project Templates.
Add Qt Bridge for C# to an existing project
For an existing macOS project, add the package:
dotnet add package QtGroup.Qt.Bridge.CSharp.osx-arm64 --version 0.5.*
The package is platform-specific because the bridge includes native build/runtime pieces for the
target platform. The 0.5.* version range stays on the 0.5 release train.
Then build and run with QtDir set, as described above:
dotnet build
dotnet run
For the full migration workflow, including QML files, startup calls, and exposing your existing C# objects to QML, see Adding QML to Existing C# Projects.
Check your setup
After the first build, check that:
- The project builds without missing Qt or toolchain errors
- The application launches
- QML files are present in the project folder
QtDirpoints to a Qt prefix containinglib/cmake/Qt6/Qt6Config.cmake
Common first issues
If the project does not build or run, check these areas first:
- The .NET SDK is missing or older than .NET 8
- The Xcode Command Line Tools, CMake, or Ninja are missing
QtDirpoints to the wrong directory, or is not set fordotnet run- Qt cannot be found by CMake