Skip to content

Commit 96d91ef

Browse files
committed
2 parents 0957b58 + 8cbdfcb commit 96d91ef

File tree

1 file changed

+81
-61
lines changed

1 file changed

+81
-61
lines changed

README.md

Lines changed: 81 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,45 @@
1-
# Build macOS Apps on Windows (CLI + GUI + Qt)
1+
# 🧰 Cross-Compile macOS Apps on Windows — C, Objective-C, Qt, Cocoa (No Mac Needed)
22

3-
**Cross-compile real macOS executables (C, Objective-C, Qt, Cocoa GUI) using Clang, CMake, and Ninja on Windows.**
3+
![Platform: Windows](https://img.shields.io/badge/platform-Windows-blue)
4+
![Builds macOS Apps](https://img.shields.io/badge/builds-macOS-brightgreen)
5+
![License: MIT (Non-Commercial)](https://img.shields.io/badge/license-MIT--NC-yellow)
46

5-
No Mac needed to build — just to run.
7+
Build native macOS applications — including Cocoa and Qt-based GUI apps — **entirely on Windows**, using Clang, CMake, and Ninja.
68

7-
---
9+
**No Mac required to build.** Just transfer and run the output on a real Mac.
810

9-
## What This Is
11+
---
1012

11-
This project is a Windows-based toolchain setup that lets you **build native macOS applications** — including **Cocoa- and Qt-based GUI apps** — using Clang and the macOS SDK.
13+
## ✨ Features
1214

13-
- Compile Objective-C, C, and Qt source files on Windows
14-
- Use CMake + Ninja (recommended) or optional standalone scripts
15-
- Build Mach-O binaries that run on real macOS
16-
- Includes working Cocoa and Qt GUI examples
15+
- Build real macOS `.app` and CLI binaries from Windows
16+
- Full support for C, Objective-C, and Qt (QtWidgets)
17+
- Cocoa GUI support (AppDelegate, XIB-style)
18+
- Works with CMake + Ninja or Visual Studio
19+
- **Automatically detects macOS SDK from `SDK/` folder**
20+
- Includes working examples: CLI, Cocoa, and Qt GUI
21+
- No VM or Hackintosh required
1722

1823
---
1924

20-
## Requirements
25+
## 📦 Overview
2126

22-
> **Note:** This setup is intended for **static Qt builds**. If you're using dynamic Qt builds, you will need to manually handle Qt plugins, frameworks, and runtime paths (`@rpath`).
27+
This project provides a cross-compilation toolchain that allows you to build native **macOS** executables — including GUI apps — from a **Windows** system. It supports:
2328

24-
To get started, you'll need:
25-
26-
- [LLVM/Clang for Windows](https://releases.llvm.org/)
27-
- [Ninja build system](https://github.com/ninja-build/ninja/releases)
28-
- [CMake (v3.10+)](https://cmake.org/download/)
29-
- [macOS SDK](https://github.com/phracker/MacOSX-SDKs/releases/tag/11.3)
30-
- [QtMacos-SDK](https://github.com/LongSoft/qt-6-static-universal-macos)
31-
- [Qt Example on GitHub](https://github.com/pyinstxtractor/Pyextract/tree/PyInstaller-Archive-Viewer)
29+
- Clang + macOS SDK
30+
- Objective-C, C, and C++ (Qt)
31+
- Cocoa GUI (with AppDelegate)
32+
- Qt Widgets-based GUI
3233

3334
---
3435

35-
## Project Structure
36+
## 📁 Project Structure
3637

3738
```
3839
MacCross/
3940
├── CMakeLists.txt
41+
├── SDK/
42+
│ └── MacOSX14.5.sdk/ # <--- Place SDK here
4043
├── C-Example/
4144
│ └── hello.c
4245
├── ObjC-Example/
@@ -46,28 +49,28 @@ MacCross/
4649
├── Qt-Example/
4750
│ ├── main.cpp
4851
├── macosx-toolchain.cmake
49-
├── build-Qt.bat # Legacy/manual build script (Qt – optional)
50-
├── build/ # Created during build
52+
├── build-Qt.bat # Optional manual script
53+
├── build/
5154
```
5255

5356
---
5457

55-
## Environment Variables (Required for Static Qt Builds)
58+
## 🔧 Requirements
5659

57-
Before running the build (CMake or manual), set the following environment variables if you're using Qt:
58-
Example setup:
59-
```cmd
60-
set QT_DIR=F:\Qt\6.7.3\macos
61-
set QT_FRAMEWORKS=%QT_DIR%\lib
62-
set MACOSX_SDK_PATH=F:\MacOs-Stuff\MacOSX14.5.sdk
63-
set MACOSX_DEPLOYMENT_TARGET=11.0
64-
```
60+
- [LLVM/Clang for Windows](https://releases.llvm.org/)
61+
- [Ninja build system](https://github.com/ninja-build/ninja/releases)
62+
- [CMake (v3.10+)](https://cmake.org/download/)
63+
- [macOS SDK](https://github.com/phracker/MacOSX-SDKs/releases/tag/11.3) (place in `SDK/` folder)
64+
- [QtMacos-SDK](https://github.com/LongSoft/qt-6-static-universal-macos)
65+
- [Qt Example on GitHub](https://github.com/pyinstxtractor/Pyextract/tree/PyInstaller-Archive-Viewer)
6566

6667
---
6768

68-
## How to Use
69+
## 🛠️ How to Build
6970

70-
### Option 1: Build with CMake + Ninja (Recommended)
71+
You can build using either CMake + Ninja (CLI) or Visual Studio (GUI). Both methods work with this project.
72+
73+
### 🔧 Option 1: CMake + Ninja (Recommended for automation or scripting)
7174

7275
```bash
7376
mkdir build
@@ -76,62 +79,79 @@ cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=../macosx-toolchain.cmake ..
7679
cmake --build .
7780
```
7881

79-
### Option 2: Manual Build Scripts (Optional / Legacy)
82+
### 🖥️ Option 2: Visual Studio (Recommended for GUI users)
83+
84+
1. Open **Visual Studio**
85+
2. Select **"Open a local folder"**
86+
3. Choose the project root (where `CMakeLists.txt` is located)
87+
4. When prompted, select a **CMake configuration** (e.g., `x64-Release`)
88+
5. Visual Studio will detect the CMake project and automatically configure it
89+
6. Ensure `macosx-toolchain.cmake` is being used:
90+
- Go to **CMake Settings** or `CMakePresets.json`
91+
- Set the toolchain file path under `CMake toolchain file`
92+
7. Build via **Build > Build All**
93+
94+
> ✅ Make sure the toolchain file is set, or builds will fail.
95+
96+
---
97+
98+
## 📌 Environment Variables (Static Qt Builds Only)
8099

81-
These scripts are provided for reference or alternative workflows. You must ensure the environment variables are properly set before running them.
100+
If you're using Qt (especially static builds), set the following environment variables before building:
82101

83102
```cmd
84-
build-Objc.bat :: for Cocoa apps
85-
build-Qt.bat :: for Qt apps
103+
set QT_DIR=F:\Qt\6.7.3\macos
104+
set QT_FRAMEWORKS=%QT_DIR%\lib
86105
```
87106

107+
> ✅ MACOSX_SDK_PATH and MACOSX_DEPLOYMENT_TARGET are automatically handled by the toolchain (SDK is detected from the SDK/ folder, deployment target is set to 11.0 by default).
108+
88109
---
89110

90-
## Verifying the Output
111+
## Verifying the Output
91112

92-
Transfer the output files to a Mac and run:
113+
Transfer the built binaries to a Mac and run:
93114

94-
```sh
95-
hello # From C-Example
96-
ObjCExample # From Cocoa app
97-
QtExample # From Qt app
115+
```bash
116+
./hello # From C-Example
117+
./ObjCExample # From Cocoa app
118+
./QtExample # From Qt app
98119
```
99120

100-
Expected CLI output:
121+
Expected output:
101122

102123
```
103124
Hello, world!
104125
```
105126

106-
> Note: Apps built this way are unsigned.
127+
> ⚠️ Note: Binaries are unsigned. You may need to bypass Gatekeeper to run them.
107128
108129
---
109130

110-
## Why Use This?
131+
## 📚 Examples Included
111132

112-
- Build macOS-native apps without a Mac
113-
- Automate macOS builds from a Windows development environment
114-
- Learn Apple toolchain internals and cross-compilation techniques
133+
- ✅ CLI C Hello World
134+
- ✅ Cocoa GUI App (Objective-C + AppDelegate)
135+
- ✅ Qt Widgets GUI App
115136

116-
---
137+
> Want Swift support? Coming soon.
117138
118-
## Examples Included
139+
---
119140

120-
- C "Hello, World"
121-
- Cocoa GUI App (Objective-C + AppDelegate)
122-
- Qt GUI App (QtWidgets-based)
141+
## 📜 License & Legal Note
123142

124-
> Want Swift? Coming soon.
143+
This project is licensed under the MIT License (with a non-commercial use clause).
144+
See the LICENSE file for more details.
125145

126146
---
127147

128-
## License & Legal Note
148+
## 💬 Feedback
129149

130-
This project is licensed under the **MIT License** (with a non-commercial use clause).
131-
See the [LICENSE](./LICENSE) file for more details.
150+
If you found this project helpful, please open an issue with suggestions or improvements.
151+
Contributions are welcome — feel free to submit a pull request!
132152

133153
---
134154

135-
## Feedback?
155+
## 🔍 Keywords
136156

137-
If you found this project helpful, please feel free to share your thoughts by opening an issue with suggestions or improvements. Contributions are always welcome — feel free to submit a pull request!
157+
macOS cross-compile • build macOS apps on Windows • Cocoa from Windows • Qt macOS SDK Windows • Clang CMake macOS • create macOS .app without Xcode • Ninja toolchain • Objective-C on Windows

0 commit comments

Comments
 (0)