Skip to content

macOS build broken with current Xcode CLT: SDL 2.30.2 fails to compile (SDL_cocoawindow.m forward-declaration error) #601

Description

@bitcoin3us

Summary

builder/unix.py checks out SDL release-2.30.2 during unix/macOS builds:

cmd_ = ['cd lib/SDL && git checkout release-2.30.2']

SDL 2.30.2 no longer compiles on macOS with current Xcode Command Line Tools (the macOS 26 SDK toolchain):

src/video/cocoa/SDL_cocoawindow.m:938:14: error: receiver type 'SDLOpenGLContext'
for instance message is a forward declaration
            [context movedToNewScreen];

Cause

The SDL build here uses SDL_OPENGL=OFF. With OpenGL off, SDLOpenGLContext's @interface (guarded by SDL_VIDEO_OPENGL_CGL in SDL_cocoaopengl.h) is never compiled — only the @class forward declaration in SDL_cocoawindow.h — while windowDidChangeScreen: messages the class unguarded. Older clang emitted a warning for messaging a forward-declared class; the current CLT promotes it to a hard error. So macOS builds work until the developer updates Command Line Tools, then break.

Fix

Upstream SDL fixed this on the SDL2 maintenance line in libsdl-org/SDL@0b6eff41 ("Fixed building on macOS with OpenGL disabled"), first shipped in 2.32.0; the 2.30.x branch never received the backport. Bumping the builder's checkout to a 2.32.x tag fixes it, e.g.:

cmd_ = [
    'cd lib/SDL && git checkout release-2.32.8 2>/dev/null '
    '|| (git fetch --tags && git checkout release-2.32.8)'
]

(The fetch fallback covers existing clones that predate the tag.)

Verified on macOS with the 26.5 SDK: 2.30.2 fails with the error above; 2.32.8 compiles cleanly and the resulting binary runs normally. Happy to open a PR if useful.

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions