# How to Build TEngine on Different Platforms: Windows, macOS, Android, iOS, WebGL, and WeChat Mini-Game

> Learn to build TEngine on Windows macOS Android iOS WebGL and WeChat Mini-Game. Follow best practices for efficient cross-platform development using Unity.

- Repository: [ALEX/tengine](https://github.com/alex-rachel/tengine)
- Tags: how-to-guide
- Published: 2026-02-24

---

**The most reliable way to build TEngine across platforms is to configure the `BuildCLI/path_define` scripts for your Unity editor path, then invoke the batch-mode methods in [`ReleaseTools.cs`](https://github.com/alex-rachel/tengine/blob/main/ReleaseTools.cs) via the provided shell or batch wrappers.**

Building **TEngine** on different platforms requires precise configuration of Unity editor paths, environment variables, and dependency workflows including **HybridCLR**, **YooAsset**, and **Luban**. The `alex-rachel/tengine` repository provides automation scripts in the `BuildCLI` directory that standardize compilation for Windows, macOS, Android, iOS, WebGL, and WeChat Mini-Game targets.

## Prerequisites for Building TEngine

Before executing any platform build, ensure your development environment meets the following requirements.

### Unity and .NET Requirements

TEngine requires **Unity 2021.3.20 f1c1 or newer**, with compatibility extending back to Unity 2019.4 and forward to 2022.3. You must use **.NET 4.x** scripting backend, supported by Visual Studio 2019+, Rider, or Visual Studio Code.

### Required Dependencies

- **HybridCLR**: Install via the Unity menu `HybridCLR/Install…` to enable hot-update functionality before building
- **YooAsset**: Run `YooAsset/AssetBundle Builder` to generate AssetBundles prior to packaging
- **Luban**: Execute config generation scripts in `Configs/GameConfig/` to produce binary config files (`.bytes`) used by the ConfigSystem

### Environment Configuration

Create a [`BuildCLI/path_define.sh`](https://github.com/alex-rachel/tengine/blob/main/BuildCLI/path_define.sh) (macOS/Linux) or `path_define.bat` (Windows) file to export `UNITYEDITOR_PATH` and `WORKSPACE` variables. This ensures all build scripts reference the correct Unity installation and project root consistently.

## Platform-Specific Build Workflows

Each target platform follows a similar pattern: source the path definitions, then execute a Unity batch-mode command calling the appropriate method in [`Assets/TEngine/Editor/ReleaseTools/ReleaseTools.cs`](https://github.com/alex-rachel/tengine/blob/main/Assets/TEngine/Editor/ReleaseTools/ReleaseTools.cs).

### Windows (Standalone)

For Windows 64-bit builds, configure `BuildCLI/path_define.bat` to point to your Unity executable:

```bat
set UNITYEDITOR_PATH=C:\Program Files\Unity\Hub\Editor\2021.3.20f1c1\Editor\Unity.exe
set WORKSPACE=C:\GitHub\tengine\UnityProject

```

While the repository provides generic scripts, you can create a dedicated `build_win64.bat` that invokes `TEngine.ReleaseTools.AutomationBuildWin64` if needed. Output binaries appear in `Build/Win64/`.

### macOS (Standalone)

Edit [`BuildCLI/path_define.sh`](https://github.com/alex-rachel/tengine/blob/main/BuildCLI/path_define.sh) to set macOS-specific paths:

```bash
export WORKSPACE="/Users/your_user/github/TEngine/UnityProject"
export UNITYEDITOR_PATH="/Applications/Unity/Hub/Editor/2021.3.20f1c1/Unity.app/Contents/MacOS/Unity"

```

Source the definitions before running the build:

```bash
cd BuildCLI
source path_define.sh
./build_android.sh  # Reuses generic ReleaseTools method; output goes to Build/MacOS/

```

### Android

Android builds require the **Android SDK and NDK** configured in Unity Preferences under External Tools.

Run the Android-specific build script located at [`BuildCLI/build_android.sh`](https://github.com/alex-rachel/tengine/blob/main/BuildCLI/build_android.sh) (lines 7-11):

```bash
cd BuildCLI
source path_define.sh
./build_android.sh

```

This script invokes `TEngine.ReleaseTools.AutomationBuildAndroid`, which compiles an APK or AAB to `Build/Android/`. The batch file `build_android.bat` provides equivalent functionality for Windows environments.

### iOS

iOS builds generate an Xcode project rather than a standalone binary. In [`ReleaseTools.cs`](https://github.com/alex-rachel/tengine/blob/main/ReleaseTools.cs) at line 152, the method `AutomationBuildIOS` sets `target = BuildTarget.iOS` before executing the build.

Command-line invocation follows this pattern:

```bash
"${UNITYEDITOR_PATH}/Unity" "${WORKSPACE}" \
  -logFile "${BUILD_LOGFILE}" \
  -executeMethod TEngine.ReleaseTools.AutomationBuildIOS \
  -quit -batchmode \
  -CustomArgs:Language=en_US "${WORKSPACE}"

```

The generated Xcode project appears in `Build/IOS/XCode_Project`. You must open this in Xcode, configure code signing, provisioning profiles, and archive manually for App Store submission.

### WebGL

WebGL builds target browser deployment using the `BuildTarget.WebGL` enumeration. Execute the `AutomationBuildWebGL` method via command line:

```bash
"${UNITYEDITOR_PATH}/Unity" "${WORKSPACE}" \
  -logFile "${BUILD_LOGFILE}" \
  -executeMethod TEngine.ReleaseTools.AutomationBuildWebGL \
  -quit -batchmode

```

Output files are written to `Build/WebGL/` and ready for deployment to static web hosting or CDN.

### WeChat Mini-Game (WXGame)

For Tencent WeChat Mini-Game deployment, TEngine implements the `AutomationBuildWXGame` method alongside other platform targets. 

1. Install **WeChat DevTools** separately
2. Set the WXGame plugin path in Unity if required
3. Duplicate the Android build script and modify the execute method to call `AutomationBuildWXGame` with `BuildTarget.WXGame`

Reference `Books/99-各平台运行RunAble.md` in the repository for visual confirmation of successful WXGame builds.

## Critical Build Steps and Verification

Several pre-build steps must complete successfully to avoid runtime errors in the compiled application.

### AssetBundle and Configuration Generation

Always generate **YooAsset** AssetBundles before platform packaging. Missing assets cause runtime null reference exceptions in builds. Similarly, execute Luban configuration scripts:

```bash
cd Configs/GameConfig
./gen_code_bin_to_server.sh   # Server-side configurations

./gen_code_bin_to_project.sh  # Client-side configurations

```

These scripts produce `.bytes` files consumed by TEngine's ConfigSystem.

### Log Inspection

All build scripts redirect Unity console output to `${BUILD_LOGFILE}`. Inspect this log immediately after any failed build to identify missing SDK paths, HybridCLR installation errors, or script compilation failures.

## Summary

- **Configure `path_define` scripts** for your specific Unity editor installation path and workspace location
- **Run dependency generators** for YooAsset (AssetBundles) and Luban (config binaries) before platform builds
- **Use batch-mode execution** via [`ReleaseTools.cs`](https://github.com/alex-rachel/tengine/blob/main/ReleaseTools.cs) methods: `AutomationBuildAndroid`, `AutomationBuildIOS`, `AutomationBuildWebGL`, and `AutomationBuildWXGame`
- **Check build logs** in `build.log` for detailed error diagnostics when builds fail
- **Manual Xcode signing** is required for iOS after the automated project generation completes

## Frequently Asked Questions

### What Unity versions are compatible with TEngine builds?

TEngine officially supports **Unity 2021.3.20 f1c1 or newer**, with functional compatibility extending from Unity 2019.4 through Unity 2022.3. The repository maintainers test primarily on LTS releases, and you must use the **.NET 4.x** scripting backend for full HybridCLR hot-update support.

### Why does my Android build fail with SDK not found errors?

The Unity editor cannot locate the Android SDK or NDK paths. Navigate to **Edit → Preferences → External Tools** in Unity and verify the Android SDK, NDK, and JDK paths are correctly set. Alternatively, install the Android Build Support module via Unity Hub with the specific NDK version bundled with your Unity installation.

### How do I resolve iOS code signing issues in TEngine builds?

The `AutomationBuildIOS` method in [`ReleaseTools.cs`](https://github.com/alex-rachel/tengine/blob/main/ReleaseTools.cs) generates an Xcode project but does not handle code signing. Open the generated project in `Build/IOS/XCode_Project/Unity-iPhone.xcodeproj`, navigate to Signing & Capabilities, select your development team, and assign a valid provisioning profile before archiving. The command-line build merely prepares the project; App Store submission requires manual Xcode intervention.

### Where are the build output files located?

TEngine places compiled artifacts in platform-specific subdirectories under the `Build/` folder: `Build/Win64/` for Windows standalone, `Build/MacOS/` for macOS, `Build/Android/` for APK/AAB files, `Build/IOS/XCode_Project` for iOS, and `Build/WebGL/` for web builds. Each platform script in `BuildCLI/` targets these directories consistently according to the path definitions set in your environment variables.