Repository navigation
Fix SwiftPM artifact permissions - #51
Merged
Merged
Conversation
birros
approved these changes
May 8, 2026
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.xcframeworkdirectories kept read-only permissions. Xcode/SwiftPM then failed to clean or re-extract binary artifacts from DerivedData withNSCocoaErrorDomain Code=513.This change creates the
.zipfiles from the writable copied archive directory instead of$src, while keeping the existing.tar.gzoutput 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.