Skip to content

feat(darwin): add Swift Package Manager support pointing at Predidit/libmpv-darwin-build 0.6.7#31

Merged
Predidit merged 8 commits into
Predidit:mainfrom
0Chencc:feat/spm-with-predidit-binaries
May 23, 2026
Merged

feat(darwin): add Swift Package Manager support pointing at Predidit/libmpv-darwin-build 0.6.7#31
Predidit merged 8 commits into
Predidit:mainfrom
0Chencc:feat/spm-with-predidit-binaries

Conversation

@0Chencc
Copy link
Copy Markdown

@0Chencc 0Chencc commented May 23, 2026

Supersedes #30 —— PR #30 漏了一个关键点:cherry-pick 来的 `Package.swift` 还指着上游 `media-kit/libmpv-darwin-build v0.7.0` 的 vanilla libmpv binary,会静默丢失本 fork 的 ad-blocker 等定制 patch。本 PR 是 #30 的修正版本,按用户工作习惯保留 #30 作为历史/讨论记录,新开本 PR 作为最终交付。

改动构成

本 PR 含 8 个 commit

为什么 commit 8 必需

集成模式 二进制来源 包含 fork patches?
既有 CocoaPods Makefile (Predidit/media-kit unchanged) `Predidit/libmpv-darwin-build/0.6.x` (.tar.gz)
PR #30 原状态(仅 cherry-pick 上游 Package.swift) `media-kit/libmpv-darwin-build/v0.7.0` (.zip) ❌ 丢失 ad-blocker
本 PR `Predidit/libmpv-darwin-build/0.6.7` (.zip)

`Predidit/libmpv-darwin-build/0.6.7` 是 Predidit/libmpv-darwin-build#4 合入后产出的首个 SPM-aware release,含:

  • 每个 xcframework 的 per-framework zip(SPM `.binaryTarget(url:)` 可消费)
  • 每个 `Mpv.framework` 内的 `Headers/` 和 `Modules/module.modulemap`(Swift `import Mpv` 必需,CocoaPods 模式下被 `media_kit_video.podspec` 的 `make` + `DEFINES_MODULE=YES` 巧妙绕过,但 SPM 直接消费 xcframework 没这步)

端到端验证

Predidit/Kazumi 上用 path override 指向本 PR 分支测试:

验证项 结果
`flutter pub get` ✅ `media_kit_video` / `media_kit_libs_macos_video` 进入 SPM packages
`flutter build macos --release` ✅ `Built Kazumi.app (123.7MB)`
Swift `import Mpv` 编译 ✅ modulemap 起作用
`codesign --verify --verbose=2 Kazumi.app` ✅ `valid on disk` + `satisfies its Designated Requirement`
`codesign --verify --deep` 递归全部嵌入 framework ✅ 18 个 SPM xcframework 全部通过
`flutter build ios --release --no-codesign` ✅ `Built Runner.app (61.6MB)`
iOS Mpv.framework codesign (ad-hoc post-process) ✅ `valid + satisfies`
iOS unsigned IPA 真机自签后运行(用户测试) ✅ 视频解析 + 播放 + ad-blocker 行为正常

证明:fork SPM zip 二进制能被 Xcode 正确签名嵌入到 .app,分发链路(含 App Store / 公证 / 真机自签)的下一步无新增障碍。

文件改动

仅修改 2 个 `Package.swift`:

  • `libs/macos/media_kit_libs_macos_video/macos/media_kit_libs_macos_video/Package.swift` (+19 / -19)
  • `libs/ios/media_kit_libs_ios_video/ios/media_kit_libs_ios_video/Package.swift` (+19 / -19)

每文件改动包含:1 行 `libmpvArtifactBase` + 18 行 sha256 替换。

不在 scope 内

  • 不动 cherry-pick 来的 commit 1-7(保留上游 author 归属 + 与上游 SPM 设计共同祖先方便未来跟进)
  • 不改 CocoaPods 链路(podspec / Makefile 完全不变,CocoaPods 用户行为 0 改动)
  • 其他平台 (Linux / Android / Windows / OHOS) 配置完全不变

下游计划

合入本 PR 后,Predidit/Kazumi 可以新开 PR 把 `pubspec.yaml` 中的 `media_kit` / `media_kit_video` / `media_kit_libs_video` 等 git `ref` bump 到本 PR 的 merge commit,让 macOS / iOS 集成把 `media_kit_video` / `media_kit_libs_{ios,macos}_video` 从 CocoaPods 兜底迁到 SPM。届时 macOS 兜底插件数 6→3, iOS 7→4。

Carapacik and others added 8 commits May 21, 2026 15:51
Revert the deployment target bumps (macOS 10.15→10.9, iOS 13.0→9.0).
The lower values match the actual targets encoded in the xcframework
binaries from media-kit/libmpv-darwin-build and should be preferred.
The minimum Flutter version was bumped to 3.27.4 to support Swift Package
Manager, but CocoaPods is still supported. There is no reason to force
developers onto a recent Flutter version until SPM becomes the only
supported option.
Previously, the SPM manifests for iOS and macOS unconditionally declared
`media_kit_libs_{ios,macos}_video` as a required dependency, causing the
build to fail if the package was not included in the developer's
`pubspec.yaml`.

The dependency is now resolved dynamically at manifest evaluation time by
checking whether the sibling package directory exists in the SPM ephemeral
packages directory. If found, `media_kit_video` is linked against it as
before; otherwise it falls back to a stub implementation, mirroring the
existing CocoaPods behavior in `media_kit_utils.rb`.

Note: after adding or removing the libs package from `pubspec.yaml`,
the SPM cache must be cleared manually:

    rm -rf ~/Library/Caches/org.swift.swiftpm/
The 7 cherry-picked SPM commits from upstream (b505adf..672ac77) reference
upstream media-kit/libmpv-darwin-build v0.7.0 binaries, which are vanilla
libmpv without this fork's ad-blocker and other patches.

Switch libmpvArtifactBase + checksums in both libs Package.swift files to
Predidit/libmpv-darwin-build 0.6.7, which is built from this fork's mpv
source (with ad-blocker + ohos + win32 + other fork-specific patches) and
includes the SPM zip + framework module map work merged in
Predidit/libmpv-darwin-build#4.

This preserves all fork customizations when downstream consumers integrate
via Swift Package Manager.

Verified end-to-end with Predidit/Kazumi:
- flutter build macos --release / iOS --release succeeded
- codesign --verify --deep on .app passes
- All 18 SPM-downloaded xcframeworks verify as signed
@Predidit Predidit merged commit 13b332a into Predidit:main May 23, 2026
Predidit pushed a commit to Predidit/Kazumi that referenced this pull request May 23, 2026
…inappwebview (#2119)

* feat: bump flutter_volume_controller to 2.0.0 for SPM support

flutter_volume_controller 2.0.0 (released 2026) adds Swift Package Manager
support for iOS and macOS, along with HarmonyOS (OHOS) support. Upgrading
from ^1.3.2 to ^2.0.0 lets Flutter integrate the plugin via SPM instead
of CocoaPods on Darwin, reducing the CocoaPods fallback list:

- macOS: 6 → 5 plugins still on CocoaPods
- iOS: 7 → 6 plugins still on CocoaPods

No API changes — existing FlutterVolumeController.getVolume / setVolume /
updateShowSystemUI / addListener / removeListener usage in player_controller
and player_playback_controller continue to work.

Verified via flutter analyze (no issues) and flutter build macos --debug.

* feat: bump media_kit fork ref to 13b332ad for SPM integration

媒体_kit fork (Predidit/media-kit) 在 [PR #31](Predidit/media-kit#31)
合入了 Swift Package Manager 适配,使 media_kit_video / media_kit_libs_{ios,macos}_video
可以在 Flutter 3.44 默认 SPM 模式下直接接入,不再走 CocoaPods 兜底。

把 pubspec.yaml 中 9 处 media_kit* 的 git ref 从 21aacaf9 (旧 fork main 头)
升到 13b332ad (PR #31 merge commit)。新 Package.swift 通过
.binaryTarget(url:) 指向 Predidit/libmpv-darwin-build 0.6.7 release 的
per-framework zip,保留 fork 的 ad-blocker 等定制 patch。

效果:CocoaPods 兜底插件数从 PR #2100 后的状态进一步缩减:
- macOS: 6 → 3 (移除 media_kit_video / media_kit_libs_macos_video / flutter_volume_controller)
- iOS:   7 → 4 (移除 media_kit_video / media_kit_libs_ios_video / flutter_volume_controller)

剩余 CocoaPods 兜底插件:
- macOS (3): screen_retriever_macos, tray_manager, flutter_inappwebview_macos
- iOS   (4): saver_gallery, open_filex, flutter_inappwebview_ios, flutter_foreground_task

本地验证:
- flutter pub get: SPM 列表含 media_kit_video / media_kit_libs_macos_video / flutter_volume_controller-2.0.0
- flutter build macos --release: Built Kazumi.app (123.7MB)
- flutter build ios --release --no-codesign: Built Runner.app (61.6MB)
- codesign --verify --deep on .app: valid + satisfies its Designated Requirement
- iOS unsigned IPA 真机自签后运行正常 (含 ad-blocker patch)

ref:
- Predidit/media-kit#31
- Predidit/libmpv-darwin-build#4
- https://github.com/Predidit/libmpv-darwin-build/releases/tag/0.6.7

* feat: bump flutter_inappwebview to 1.2.0-beta.3 for SPM support

flutter_inappwebview 1.2.0-beta.3 (platform_interface 1.4.0-beta.3) adds
Swift Package Manager support for iOS and macOS. The beta line has been
running since 2024-11 (~18 months) while the stable line has been frozen
at 1.1.x since 2024-10 — maintainer is shipping SPM + many new features
through the beta channel, so adopting beta is the practical path.

Bumps:
- flutter_inappwebview_platform_interface: ^1.3.0+1 → ^1.4.0-beta.3
- flutter_inappwebview_ios:                 ^1.1.2 → ^1.2.0-beta.3
- flutter_inappwebview_macos:               ^1.1.2 → ^1.2.0-beta.3
- flutter_inappwebview_android:             ^1.1.3 → ^1.2.0-beta.3

Final CocoaPods fallback count after this commit:
- macOS: 3 → 2 (removes flutter_inappwebview_macos)
- iOS:   4 → 3 (removes flutter_inappwebview_ios)

Remaining CocoaPods fallback (waiting on upstream SPM adoption):
- macOS (2): screen_retriever_macos, tray_manager
- iOS   (3): saver_gallery, open_filex, flutter_foreground_task

API compatibility verified — Kazumi's WebView code in lib/webview/video/impl/
uses lambdas for JavaScript handlers and load callbacks, which remain
compatible with the beta API (deprecated typedef JavaScriptHandlerCallback
is only referenced indirectly; Future → FutureOr return type widening is
backward compatible with async lambdas).

Verified locally:
- flutter analyze lib/webview/: no errors, no deprecation warnings
- flutter build macos --release: Built Kazumi.app (129.3MB)
- flutter build ios --release --no-codesign: Built Runner.app (64.6MB)
- codesign --verify --deep: valid + satisfies its Designated Requirement
- Runtime: video parsing + playback + danmaku + ad-blocker behavior
  unchanged across multiple plugin sources on macOS
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.

4 participants