Skip to content

extplane-plugin: fix macOS build for Apple Silicon (X-Plane SDK 4.x) - #85

Open
BhSimon wants to merge 1 commit into
vranki:masterfrom
BhSimon:macos-apple-silicon-build
Open

extplane-plugin: fix macOS build for Apple Silicon (X-Plane SDK 4.x)#85
BhSimon wants to merge 1 commit into
vranki:masterfrom
BhSimon:macos-apple-silicon-build

Conversation

@BhSimon

@BhSimon BhSimon commented Sep 6, 2026

Copy link
Copy Markdown

Fix macOS build for Apple Silicon (X-Plane SDK 4.x)

Summary

This PR makes extplane-plugin/extplane-plugin.pro build a native arm64 mac.xpl,
verified loading and streaming datarefs in X‑Plane 12 on an M2 Mac.

All changes are in extplane-plugin/extplane-plugin.pro.

What was broken

  1. CONFIG += x86 ppc in the macx {} block forced a 32‑bit Intel +
    PowerPC build. That fails on any modern macOS toolchain and makes an arm64
    build impossible. Removed — the plugin now builds for the architecture(s)
    of the Qt it links against (arm64 on Apple Silicon; universal if you link a
    universal Qt and add -arch flags).

  2. XPLMCommandKeyStroke / XPLMCommandButtonPress / XPLMCommandButtonRelease
    (used in xplaneplugin.cpp) are gated behind XPLM_DEPRECATED in the
    X‑Plane SDK 4.x headers, so the plugin fails to compile with a current SDK:

    xplaneplugin.cpp:184:5: error: use of undeclared identifier 'XPLMCommandKeyStroke'
    

    The functions are still exported by XPLM.framework, so defining
    XPLM_DEPRECATED restores them. Harmless with SDK 3.x.

  3. libmosquittopp was linked unconditionally via pkg-config, even though
    the MQTT sources are already guarded by CONFIG(mqtt). A default
    (non‑MQTT) build therefore failed unless mosquitto was installed. Moved the
    pkg-config link under the same CONFIG(mqtt) guard.

How to build on Apple Silicon

macOS 14+ can use Homebrew qt@5. On macOS 13 (Ventura) Homebrew has no
arm64 Qt5 bottle; conda‑forge works (its osx‑arm64 build targets macOS 11+):

# arm64 Qt5 (only needed if you don't have one)
mamba create -n xplane-qt5 -c conda-forge qt-main=5.15
export PATH="$CONDA_PREFIX/envs/xplane-qt5/bin:$PATH"

# X-Plane SDK 4.x next to the ExtPlane checkout (its Mac framework is arm64+x86_64)
#   ../XPlaneSDK  ->  SDK 4.x

cd ExtPlane && qmake && make          # builds extplane-plugin/extplane/mac.xpl (arm64)

Because the Qt5 comes from a non‑system prefix, the resulting .xpl references
Qt via @rpath; bundle libQt5Core, libQt5Network and their deps (ICU, z,
zstd) next to mac.xpl and rewrite install names to @loader_path for a
self‑contained plugin.

Verification

  • Builds an arm64 mac.xpl against X‑Plane SDK 4.3.0 + Qt 5.15.
  • minos 11.0, exports XPluginStart/Stop/Enable/Disable/ReceiveMessage.
  • Loads in X‑Plane 12 on Apple Silicon: Loaded: .../ExtPlane/mac.xpl (org.vranki.extplaneplugin) and ExtPlane listening on TCP port 51000.
  • Subscribing over TCP streams live datarefs (ud/uf/ui frames).
  • In the same aircraft, x86_64‑only plugins failed with
    incompatible architecture (have 'x86_64', need 'arm64') — confirming
    X‑Plane ran native arm64 and this plugin matched.

Three issues in extplane-plugin.pro, all fixed here:

1. The macx block forced `CONFIG += x86 ppc`, i.e. 32-bit Intel + PowerPC.
   That breaks on any modern macOS toolchain and prevents an arm64 build.
   Removed; the plugin now builds for the architecture(s) of the Qt it is
   linked against (arm64 on Apple Silicon, or universal with a universal Qt).

2. XPLMCommandKeyStroke / XPLMCommandButtonPress / XPLMCommandButtonRelease
   (used in xplaneplugin.cpp) are gated behind XPLM_DEPRECATED in the
   X-Plane SDK 4.x headers, though the framework still exports them. Define
   XPLM_DEPRECATED so the plugin compiles against SDK 4.x. Harmless on 3.x.

3. libmosquittopp was linked unconditionally via pkg-config even though the
   MQTT sources are already guarded by `CONFIG(mqtt)`. Move the pkg-config
   link under the same guard so a default (non-MQTT) build does not require
   mosquitto to be installed.

Verified: produces an arm64 mac.xpl against X-Plane SDK 4.3.0 with Qt 5.15;
loads in X-Plane 12 on an Apple Silicon Mac and streams datarefs over TCP 51000
(x86_64-only plugins in the same session failed with an arch mismatch).

LLM assistance: Claude Opus 4.8
@BhSimon
BhSimon force-pushed the macos-apple-silicon-build branch from c1ee9f0 to 84340b3 Compare September 6, 2026 04:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant