← Back to Pull requests

Build macOS frameworks in the versioned bundle layout #3084

Closed
unknown closed this pull request without merging on Sep 29, 2026 18:44 UTC
View on GitHub
unknown unknown commented on Sep 28, 2026 02:10 UTC
Author

<!-- ccr-projects-attribution: {"github_login":"rickmark"} -->
_Requested by Rick_

Problem

macos_framework and macos_dynamic_framework build flat bundles, iOS style: the binary, Info.plist, Headers, Modules and resources all sit at the top of Foo.framework. macOS frameworks are versioned bundles (Apple's Anatomy of Framework Bundles): the contents live in Versions/A, Versions/Current links to A, and each top-level entry is a link to Versions/Current/<entry>.

dyld, codesign --verify --deep --strict and notarization all accept a flat framework. App Store Connect rejects an app that embeds one:

  • ITMS-90291: malformed framework

  • ITMS-90292: invalid bundle structure
  • So today a Mac App Store app can't ship a framework built by rules_apple.

    Change

    macOS frameworks are now built in the versioned layout. It's the default for every macOS framework, with no opt-in, because the flat layout isn't valid on macOS.

  • rule_support.bzl: _describe_bundle_locations gains bundle_version. The macOS framework descriptor uses Versions/A as its contents directory, with resources in Resources.

  • processor.bzl: in a versioned bundle, files placed at the bundle root (Headers, Modules) go in the version directory. The control file lists the links to create: Versions/Current -> A, plus <entry> -> Versions/Current/<entry> for each top-level entry of the version. _CodeSignature is left out; codesign writes it inside the version.

  • bundletool.py and bundletool_experimental.py: a new bundle_symlinks control key. bundletool.py writes zip symlink entries; tree-artifact mode writes real links through the existing _write_symlink, with its bundle-escape checks.

  • partials/resources.bzl: the root Info.plist goes in Versions/A/Resources.

  • macos_rules.bzl: the install name is @rpath/<Name>.framework/Versions/A/<Name>, which is what Xcode sets.
  • Existing paths such as Foo.framework/Foo and Foo.framework/Headers/... still resolve, through the top-level links. Foo.framework/Info.plist and root-level resources move under Resources/.

    Tests

  • test/starlark_tests/macos_framework_tests.bzl and macos_dynamic_framework_tests.bzl now expect:

  • - Info.plist and resources under Resources/;
    - the versioned install name, both in the framework's LC_ID_DYLIB and in apps' LC_LOAD_DYLIB.

    The not_contains assertions moved to the new locations as well, so they still test something.
  • New verifier_scripts/versioned_framework_verifier.sh checks:

  • - Versions/A is a real directory;
    - Versions/Current -> A;
    - the binary is in Versions/A, with a link at the top;
    - Info.plist is in Versions/A/Resources;
    - every top-level entry except Versions is a link into Versions/Current.

    It runs as macos_framework_versioned_bundle_layout_test and macos_dynamic_framework_versioned_bundle_layout_test.
  • bundletool_test and bundletool_experimental_test cover bundle_symlinks.
  • On macOS (Xcode 26), all 169 tests in these targets pass:

    bazel test //test/starlark_tests:macos_framework //test/starlark_tests:macos_dynamic_framework \
      //test/starlark_tests:macos_application //test/starlark_tests:macos_bundle \
      //test/starlark_tests:apple_xcframework //tools/bundletool:all
    

    On main without this change, 21 of the macOS framework tests fail against the new expectations. They were written for the flat layout.

    I also checked a real app outside the test suite: an app embedding a macos_framework built with this change (applied to rules_apple 5.1.0, where it applies unchanged), archived for the Mac App Store. It passed App Store Connect validation. codesign --verify --deep --strict passed on the archived app, and the app launched.

    I did not add a tree-artifact variant of the verifier test. I checked the tree-artifact output by hand and the links are real. But the test harness dereferences them when it stages a tree artifact into the sandbox, so the test can't see them.

    A gap for reviewers

    apple_xcframework goes through the same processor. Its macOS slice now gets the versioned layout too, which matches Xcode-built XCFrameworks. Its install name, though, stays @rpath/<Name>.framework/<Name>: the rule links every platform with one set of extra_linkopts, so the macOS slice can't get a different -install_name without per-platform linkopts. That name still resolves through the top-level link. I kept this PR to the macOS framework rules. I'm happy to add per-platform install names here, or in a follow-up, if you'd like.

    🤖 Generated with Claude Code

    Diff: 599 lines (+449 / -150) across 7 files Reviewer: aaronsky Review duration: 2434m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.50) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.50 · 599 lines diff across 7 files
    0.50
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.383
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3084"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 50.1% (MEDIUM) · Higher = larger blast radius
    50.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.6% · Safe to merge
    21.6%