Skip to content

Fix macOS framework layout so the inner bundle can be signed - #39

Merged
FeodorFitsner merged 1 commit into
mainfrom
fix-macos-framework-layout
Jul 30, 2026
Merged

Fix macOS framework layout so the inner bundle can be signed#39
FeodorFitsner merged 1 commit into
mainfrom
fix-macos-framework-layout

Conversation

@FeodorFitsner

Copy link
Copy Markdown
Contributor

Fixes the signing job failure in run 30580489055.

The failure

Every python-macos-dart-* archive died with:

Python.xcframework/macos-arm64_x86_64/Python.framework:
  unsealed contents present in the root directory of an embedded framework

All nine iOS archives signed fine first — this is macOS-only.

Cause

macOS frameworks are versioned bundles: everything at the framework root must be a symlink into Versions/Current, and only Versions itself may be a real directory. package-macos-for-dart.sh wrote the overlaid Modules and the public Headers as real directories at the root:

Python.framework/
  Headers/     ← real directory   ✗
  Modules/     ← real directory   ✗
  Python    -> Versions/Current/Python
  Resources -> Versions/Current/Resources
  Versions/

That was invisible while only the outer xcframework was signed — the outer seal doesn't care — and became fatal the moment #38 started signing the inner framework in its own right.

They now go into Versions/Current with symlinks at the root, which is what codesign requires and what CPython's own macOS framework already does for Headers and Resources. Consumers resolve Headers/ and Modules/ through the symlinks exactly as before.

A second bug the same run exposed

The verifier probed for _CodeSignature or Versions/A/_CodeSignature. But a versioned bundle's version directory isn't always A — CPython's macOS framework uses Versions/3.14 — so a correctly signed macOS framework was reported as unsigned. It now asks codesign -dv, which is layout-agnostic and is the actual question being asked.

Worth noting these two bugs masked each other during review: the layout bug made signing fail, and the verifier bug would have made it fail again right afterwards for a different reason.

Verified with the real identity

Against the released 20260729 macOS archive:

scan for real dirs at a versioned framework root:
  Python.xcframework/macos-arm64_x86_64/Python.framework   Headers Modules   ← reproduced

after the fix:
  xcframework-signing: signing xcframeworks/Python.xcframework as dev.flet.python.runtime (1 slice framework(s) + outer)
  xcframework-signing: verified xcframeworks/Python.xcframework
  Identifier=dev.flet.python.runtime
  Authority=Apple Distribution: Appveyor Systems Inc. (GXXRQJK434)
  Timestamp=Jul 30, 2026 at 2:21:42 PM
  TeamIdentifier=GXXRQJK434
  • dart_bridge v1.7.1 (Versions/A layout) still verifies — the verifier change is layout-agnostic, not macOS-specific
  • headers still reachable through the symlink (Headers/Python.h, Modules/module.modulemap)
  • stripping the inner signature still fails the run

The same verifier fix goes to flet-dev/dart-bridge to keep the two helper copies byte-identical.

The signing job failed on every python-macos-dart archive with:

  Python.framework: unsealed contents present in the root directory of
  an embedded framework

macOS frameworks are VERSIONED bundles: everything at the framework root must be
a symlink into Versions/Current, and only `Versions` itself may be a real
directory. package-macos-for-dart.sh wrote the overlaid `Modules` and the public
`Headers` as real directories at the root. That was invisible while only the
outer xcframework was signed -- the outer seal does not care -- and became fatal
the moment the inner framework was signed in its own right.

They now go into Versions/Current with symlinks at the root, which is both what
codesign requires and what CPython's own macOS framework already does for Headers
and Resources. Consumers resolve Headers/ and Modules/ through the symlinks
exactly as before.

Also fixes the verifier, which was wrong in a way the same run exposed: it probed
for `_CodeSignature` or `Versions/A/_CodeSignature`, but a versioned bundle's
version directory is not always "A" -- CPython's macOS framework uses
Versions/3.14 -- so a correctly signed macOS framework was reported as unsigned.
It now asks `codesign -dv`, which is layout-agnostic and is the actual question.

Verified with the real identity against the released 20260729 macOS archive:
inner and outer both sign and verify, dart_bridge v1.7.1 (Versions/A) still
verifies, and stripping the inner signature still fails the run.
FeodorFitsner added a commit to flet-dev/dart-bridge that referenced this pull request Jul 30, 2026
xcf_verify_one probed for `_CodeSignature` or `Versions/A/_CodeSignature`. A
versioned bundle keeps its signature at Versions/<name>/_CodeSignature, and the
version directory is not always "A": CPython's macOS framework uses the Python
version, e.g. Versions/3.14. A correctly signed framework there was therefore
reported as unsigned.

dart_bridge's own macOS slice does use Versions/A, so this never fired here --
it surfaced in python-build, whose Python.framework does not
(flet-dev/python-build#39).

Ask `codesign -dv` instead. It exits non-zero with "code object is not signed at
all", which is precisely the question, and it is layout-agnostic.

Verified: v1.7.1 still verifies, a macOS framework using Versions/3.14 now
verifies, and stripping an inner signature still fails.

Keeps this helper byte-identical to python-build's copy.
@FeodorFitsner
FeodorFitsner merged commit 91eff8c into main Jul 30, 2026
9 of 21 checks passed
@FeodorFitsner
FeodorFitsner deleted the fix-macos-framework-layout branch July 30, 2026 21:26
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