Skip to content

Fix SwiftPM artifact permissions - #51

Merged
birros merged 1 commit into
media-kit:mainfrom
Carapacik:spm
May 8, 2026
Merged

birros merged 1 commit into
media-kit:mainfrom
Carapacik:spm

Conversation

@Carapacik

@Carapacik Carapacik commented May 8, 2026 •

Copy link
Copy Markdown
Contributor

This fixes the SwiftPM zip packaging for xcframework artifacts.

Previously the zip files were created directly from $src, which points to the Nix store. As a result, the extracted .xcframework directories kept read-only permissions. Xcode/SwiftPM then failed to clean or re-extract binary artifacts from DerivedData with NSCocoaErrorDomain Code=513.

This change creates the .zip files from the writable copied archive directory instead of $src, while keeping the existing .tar.gz output unchanged.

Tested with media_kit_test, where the current v0.7.0 artifacts fail during SwiftPM package resolution because the extracted binary artifacts are read-only.

Needed for media-kit/media-kit#1412.

@birros
birros merged commit ee11358 into media-kit:main May 8, 2026
1 check passed
@Carapacik
Carapacik deleted the spm branch May 8, 2026 17:10
Predidit pushed a commit to Predidit/libmpv-darwin-build that referenced this pull request May 23, 2026
* feat(spm): emit per-framework zip artifacts for xcframeworks builds

Allows downstream Swift Package Manager consumers (e.g. media_kit's
Package.swift via `.binaryTarget(url:)`) to reference individual
xcframework binaries directly, removing the need for CocoaPods fallback
on iOS / macOS.

Each xcframework target now produces both:
  - libmpv-xcframeworks_<VER>_<PLAT>-universal-<VAR>-<FLAVOR>.tar.gz
    (existing, untouched, consumed by current CocoaPods Makefiles)
  - libmpv-xcframeworks_<VER>_<PLAT>-universal-<VAR>-<FLAVOR>_<Framework>.zip
    (new, one zip per *.xcframework, matches upstream media-kit naming)

Changes:
  - nix/packages/mk-out-archive/default.nix:
    * rename archiveName -> archiveBaseName (drop .tar.gz suffix)
    * add nativeBuildInputs [ pkgs.zip ] guarded by xcframeworks format
    * append xcframeworks-only zip loop via pkgs.lib.optionalString
    * stabilize build path with $build=$PWD/build
  - nix/packages/mk-out-all/default.nix:
    * include *.zip in artifact aggregation
    * add `shopt -s nullglob` defense so libs-format archives
      (which have no zips) don't trip the cp glob
  - .github/workflows/ci.yaml:
    * include result/*.zip in upload-artifact and release file lists

Design notes:
  - libs-format builds are unchanged (optionalString guard keeps zip
    loop xcframeworks-only); fully backward compatible with existing
    CocoaPods integrations.
  - Naming pattern intentionally matches upstream media-kit/libmpv-darwin-build
    (Carapacik/spm, PR media-kit#51) so downstream Package.swift can
    swap only the URL host without changing structure.
  - Minimal patch: this commit deliberately does NOT pull in upstream's
    later nix-flake / xcode-setup / action-version refactors. Scope is
    confined to "emit SPM-compatible zips".

Locally verified:
  - `nix eval` on xcframeworks-format mk-out-archive renders the zip
    loop in buildPhase as expected.
  - `nix eval` on libs-format renders WITHOUT the zip loop (no-op
    confirmation).
  - Full `nix build` not run locally (requires Xcode injection into
    /nix/store, multi-hour build). Will rely on CI for end-to-end build
    verification.

* feat(mk-out-frameworks): add headers and module map to Mpv.framework

Mpv.framework requires public headers and a module map to be importable
as a Swift module. Add them for both macOS (versioned layout under
Versions/A/) and iOS (flat layout at the framework root).

Headers are extracted from the mpv package into a standalone derivation
and passed to the build scripts via MPV_HEADERS_PATH. An umbrella header
(Mpv.h) is generated to re-export all of them, as expected by the module
map. For universal builds, arm64 headers are used as they are very likely
identical to their amd64 counterparts.

Note: ideally headers and the module map should be bundled per-framework
derivation rather than injected globally from the dylib-based build loop.

---------

Co-authored-by: birros <birros@protonmail.com>
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.

2 participants