Skip to content

macOS: static-link, drop SDL2_image, ad-hoc sign — no more Gatekeeper prompts#3

Merged
eggfly merged 1 commit into
mainfrom
fix/macos-static-no-quarantine
Jun 3, 2026
Merged

macOS: static-link, drop SDL2_image, ad-hoc sign — no more Gatekeeper prompts#3
eggfly merged 1 commit into
mainfrom
fix/macos-static-no-quarantine

Conversation

@eggfly

@eggfly eggfly commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Problem

Downloading a macOS build and launching it fired the Gatekeeper prompt 22 times — once per bundled dylib ("Apple 无法验证 libSDL2_image…"). The bundle carried 22 third-party dylibs (SDL2_image + its avif/jxl/webp/tiff/lcms/aom/dav1d/… transitive tree), none signed/notarized, each quarantined.

Fix — stop shipping third-party dylibs on macOS

  1. Drop SDL2_imagesrc/png_to_sdl_surface.{c,h} loads PNG via LVGL's bundled lodepng. Emulator only loaded one PNG (device skin); APPLaunch icons already use LV_USE_LODEPNG.
  2. Static link SDL2/Freetype/libpng (EMU_MACOS_STATIC_DEPS=ON). otool -L shows zero homebrew refs — CI asserts it.
  3. Ad-hoc codesign executable + app dylibs, strip quarantine xattr.
  4. Ship both green zip and DMG.

Result

  • ✅ No Gatekeeper prompts on fresh download
  • ✅ Bundle 10.8MB → 6.2MB (~40% smaller)
  • ✅ Windows / Linux / Web untouched
  • arm64 only

Local: otool -L clean, signed static binary runs + renders skin; sign+zip+dmg flow exercised end-to-end.

Kills the Gatekeeper 'Apple cannot verify libSDL2_image…' prompt that
fired once per bundled dylib (22 times) on first launch of a downloaded
macOS build.

Root cause: the bundle shipped 22 third-party dylibs (SDL2_image and its
whole avif/jxl/webp/tiff/lcms/… transitive tree), none signed/notarized,
each quarantined.

Changes:
- src/png_to_sdl_surface.{c,h}: load PNG via LVGL's bundled lodepng instead
  of SDL2_image. The emulator only ever loaded one PNG (the device skin)
  and only IMG_INIT_PNG, so SDL2_image was pure overhead. APPLaunch icons
  already decode through LVGL's LV_USE_LODEPNG, untouched.
- src/main.cpp / main_web.cpp: use load_png_as_sdl_surface(), drop SDL_image.
- CMakeLists.txt: remove SDL2_image entirely. Add EMU_MACOS_STATIC_DEPS=ON
  (default) — statically link libSDL2.a + libfreetype.a + libpng16.a with the
  Cocoa/CoreAudio/etc frameworks SDL2 needs. Result: cardputer-emu has zero
  third-party dylib references (verified via otool -L in CI).
- build.yml macos job: install sdl2/freetype/libpng (no sdl2_image), build
  static, ad-hoc codesign every Mach-O (cardputer-emu + our two app dylibs),
  strip the quarantine xattr, and produce BOTH a green zip and a DMG.

Bundle size dropped ~40% (10.8MB → 6.2MB). Windows / Linux / Web unchanged.
@eggfly eggfly merged commit bbe4507 into main Jun 3, 2026
4 of 5 checks passed
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