130 Widgets

Building tools. Learning to build tools. Learning to build learning tools.

3. KSPlayer — Dependencies and Licenses Arch

Every dependency you add to a project is a contract. You get capability; in return you accept maintenance burden, API stability risk, and — often overlooked — license obligations. KSPlayer is a single SPM entry in project.yml, but understanding what it brings along and what you’re agreeing to is worth a dedicated section. The license situation here is more consequential than it first appears.

What KSPlayer Is

KSPlayer is an open-source Swift video player for iOS, macOS, and tvOS. Its distinguishing characteristic is that it wraps FFmpeg — the ubiquitous open-source media toolkit — as its decoding and networking backend, while presenting a Swift-friendly API.

KSPlayer ships as an XCFramework containing pre-compiled FFmpeg for all Apple platforms and architectures. This means:

The License Stack

KSPlayer’s Swift code is licensed under GPL v3 — the GNU General Public License, version 3. This is not a permissive license. It is a strong copyleft license with significant implications for distribution. The components it bundles have their own terms:

Component License Implication
KSPlayer Swift code GPL v3 Dominant license. Governs distribution of any app that includes it. See discussion below.
FFmpeg core (libavcodec, libavformat, libavutil, libswscale) LGPL 2.1+ Less restrictive than GPL, but the KSPlayer GPL wrapper is what matters here.
libshaderc_combined Apache 2.0 Permissive. Retain license and NOTICE file.

The LGPL of FFmpeg doesn’t soften the situation — because the Swift code that calls into FFmpeg (KSPlayer itself) is GPL v3, any app that incorporates KSPlayer is subject to GPL v3 terms. The most restrictive license in a combined work governs.

What GPL v3 Actually Requires

The GPL v3 is a copyleft license. Its core requirement is:

If you distribute a program that incorporates GPL-licensed code, you must distribute that program’s complete source code under the GPL as well.

This is the “viral” property of the GPL: the license propagates. FredCam’s own Swift code — the state machine, the layout, the settings view — all of it would need to be released as GPL v3 source if you distribute an app that links against KSPlayer.

There is one important carve-out: GPL only applies to distribution. If you never distribute the app — you build it in Xcode, install it on your own phone via cable, and use it yourself — GPL imposes no obligations whatsoever. The license does not restrict private use.

What This Means for FredCam

Sideloading FredCam to your own device from Xcode: completely fine. GPL v3 has no bearing on personal, non-distributed use.

Distributing via TestFlight to friends: requires either open-sourcing FredCam under GPL v3, or obtaining a commercial license from the KSPlayer maintainer.

Submitting to the App Store as a closed-source app: same as above — a GPL violation unless you comply or relicense.

Dual Licensing: The Commercial Option

KSPlayer uses a common commercial open-source model called dual licensing. The maintainer offers two paths:

Dual licensing is a legitimate and well-established model — Qt, MySQL, and many other major projects use it. The GPL edition builds a user community and provides free exposure; the commercial license funds development. If you wanted to ship FredCam commercially without open-sourcing it, a paid KSPlayer license would be the path.

Architecture Concept

An alternative to paying for an LGPL license is to replace KSPlayer with your own thin wrapper that links directly against FFmpeg’s LGPL-licensed XCFrameworks — without using any KSPlayer Swift code. FFmpeg itself is LGPL; it’s the KSPlayer layer on top that adds the GPL. Building a direct FFmpeg integration is more work (no KSPlayerLayer convenience layer), but you’d be free of the GPL obligation. This is covered in more detail in Section 9.

Alternatives and License Comparison

Option License Tradeoffs
KSPlayer (current) GPL v3 (or paid commercial) Works today. Free for personal/open-source use. Distribution of closed-source app requires paid license.
Direct FFmpeg integration LGPL 2.1 No GPL exposure. Requires writing your own Swift wrapper around FFmpeg’s C API. Significant but focused effort.
VLCKit LGPL Can’t bypass self-signed cert without source rebuild. Build from source is complex. LGPL is easier than GPL.
Native RTSPS client None (Apple frameworks only) Zero license exposure. Requires implementing RTSP negotiation, RTP parsing, and H.264 demuxing manually. Weeks of work.
Open-source FredCam (GPL) GPL v3 (your app too) Fully compliant with KSPlayer’s license. No payment required. Means publishing FredCam’s source publicly under GPL.
AVPlayer over HLS None (Apple frameworks) Only viable if Bambu Lab adds HLS support. Currently RTSPS only.
Not Legal Advice

This section summarizes GPL v3 as commonly understood. It is not legal advice. If you intend to distribute FredCam commercially or to a general audience, consult a lawyer familiar with open-source licensing before doing so. The FSF’s GPL FAQ and the Software Freedom Law Center are useful starting points.

Summary

KSPlayer is licensed under GPL v3, not a permissive license. GPL v3 requires that any distributed app incorporating KSPlayer also be released under GPL v3. For personal, non-distributed use, there are no obligations. For closed-source distribution, the options are: purchase a commercial license from the KSPlayer maintainer, replace KSPlayer with a direct FFmpeg integration (LGPL), or publish FredCam’s own source under GPL v3.