Skip to content

Fix build compatibility with Xcode 26 / modern toolchains#1371

Open
GeiserX wants to merge 2 commits intoovertake:masterfrom
GeiserX:fix/xcode-26-build-compat
Open

Fix build compatibility with Xcode 26 / modern toolchains#1371
GeiserX wants to merge 2 commits intoovertake:masterfrom
GeiserX:fix/xcode-26-build-compat

Conversation

@GeiserX
Copy link
Copy Markdown

@GeiserX GeiserX commented Apr 23, 2026

Summary

  • Add missing Homebrew dependencies (nasm, meson) to INSTALL.md
  • Fix CMake policy deprecation error in Mozjpeg build script
  • Fix ffmpeg version mismatch in build script (7.17.1.1)
  • Document additional submodule-level issues and Metal Toolchain workaround for Xcode 26

Context

Building TelegramSwift from source on Xcode 26 (macOS 26 / Tahoe) with CMake 3.31 surfaces several issues, ranging from missing documented dependencies to CMake policy errors, ffmpeg version mismatches, and clang compatibility breaks. This PR addresses the issues fixable within the main repository and documents workarounds for environment-level issues.

All issues discovered during the Xcode 26 build:

  1. Missing brew dependenciesmeson (required by the dav1d build script) and nasm (required by the OpenH264 build script) are not listed in INSTALL.md, causing configure_frameworks.sh to fail for first-time builders.
  2. CMake policy deprecation error — CMake 3.27+ enforces CMP0000 strictly when cmake_minimum_required is set to a very old version. The Mozjpeg build fails with: CMake Error at CMakeLists.txt — Policy "CMP0000" is not known to this version of CMake. Adding -DCMAKE_POLICY_VERSION_MINIMUM=3.5 resolves this.
  3. ffmpeg version mismatch — The ffmpeg build script (core-xprojects/ffmpeg/ffmpeg/build.sh) sets FF_VERSION="7.1" but the bundled source in telegram-ios submodule is at ffmpeg-7.1.1, causing the build to fail with "FFmpeg source not found".
  4. Metal Toolchain libswiftAppKit.dylib missing — Xcode 26's Metal Toolchain is mounted as a read-only cryptex at /var/run/com.apple.security.cryptexd/mnt/com.apple.MobileAsset.MetalToolchain-*/Metal.xctoolchain/ but does NOT contain usr/lib/swift-5.0/macosx/libswiftAppKit.dylib. The linker is passed this path directly and fails. See Workaround below.
  5. ABSL_ATTRIBUTE_LIFETIME_BOUND clang error (submodule: tg_owt) — Xcode 26's clang rejects [[clang::lifetimebound]] on parameters of void-returning functions. Affects submodules/tg_owt/src/api/candidate.h line 108 in set_type().

Changes in this PR

INSTALL.md

Added nasm and meson to the brew install command in step 3.

core-xprojects/Mozjpeg/Mozjpeg/build.sh

Added -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to the CMake invocation. Required for CMake 3.27+ compatibility.

core-xprojects/ffmpeg/ffmpeg/build.sh

Updated FF_VERSION from "7.1" to "7.1.1" to match the actual bundled ffmpeg source directory in the telegram-ios submodule.

Metal Toolchain Workaround

On Xcode 26, the Metal Toolchain cryptex mount doesn't include Swift compatibility libraries. The linker receives an explicit path to libswiftAppKit.dylib inside the Metal Toolchain that doesn't exist. Since the cryptex is read-only, symlinks cannot be added.

Workaround: Use an LD wrapper script that intercepts the linker invocation and remaps the Metal Toolchain path to the Xcode default toolchain:

#!/bin/bash
XCODE_LIB="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.0/macosx/libswiftAppKit.dylib"
args=()
for arg in "$@"; do
    if [[ "$arg" == /var/run/com.apple.security.cryptexd/mnt/com.apple.MobileAsset.MetalToolchain-*/Metal.xctoolchain/usr/lib/swift-5.0/macosx/libswiftAppKit.dylib ]]; then
        args+=("$XCODE_LIB")
    else
        args+=("$arg")
    fi
done
exec /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang "${args[@]}"

Save as /tmp/ld-wrapper.sh, chmod +x, then build with:

LD=/tmp/ld-wrapper.sh LDPLUSPLUS=/tmp/ld-wrapper.sh xcodebuild build ...

Submodule issues (upstream)

These issues cannot be fixed in the main TelegramSwift repo:

  • tg_owtsrc/api/candidate.h:108: ABSL_ATTRIBUTE_LIFETIME_BOUND on set_type() parameter causes a clang error on Xcode 26. Fix: remove the attribute from that parameter, or update abseil.

Test plan

  • Clone fresh with --recurse-submodules on macOS with Xcode 26
  • Run brew install cmake ninja openssl@1.1 zlib autoconf libtool automake yasm nasm meson pkg-config
  • Run configure_frameworks.sh — all 10 frameworks build successfully
  • Build app with LD wrapper — binary produced successfully
  • Verify Mozjpeg framework builds without CMake policy errors
  • Verify ffmpeg framework builds without version mismatch errors

GeiserX added 2 commits April 23, 2026 21:13
Add missing brew dependencies (nasm, meson) required by dav1d and
OpenH264 build scripts. Add CMAKE_POLICY_VERSION_MINIMUM=3.5 to
Mozjpeg build to fix cmake 3.27+ policy deprecation error.
The ffmpeg build script references ffmpeg-7.1 but the bundled source
in telegram-ios submodule is ffmpeg-7.1.1, causing build failures.
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