dmrschmidt / DSWaveformImage

Generate waveform images from audio files on iOS, macOS & visionOS in Swift. Native SwiftUI & UIKit views.
MIT License
978 stars 109 forks source link

Support for older versions of macOS #99

Closed dvkch closed 1 month ago

dvkch commented 1 month ago

Hello there,

First of all congrats on an amazing library! The amount of work to achieve this is impressive, so thank you!

I am currently trying to integrate it into an app that currently builds for macOS 10.13+. Using the library currently requires changing that target to macOS 12.0 which I would like to avoid if possible.

If I am not mistaken, the parts that doesn't involve SwiftUI doesn't seem to require that high of a version, do you reckon it would be possible to lower the required macOS version for the whole package and add @available statements to the views ?

I imaging that can be a bother, so if that's not something you're inclined to do I'd completely understand. If it is something you would allow, I'm also ready to make a PR.

Thanks for considering!

dmrschmidt commented 1 month ago

Hey @dvkch, the macOS build only supports views using SwiftUI. There’s only UIKit and SwiftUI, but no AppKit version. So removing SwiftUI would remove all UI support for macOS.

I’m not exactly sure from top of my head what would be required to enable support for macOS 10.13. When macOS support initially got introduced, it was already for at least 12. As I’m not a macOS developer myself, I’m not super in depth with the differences between versions, but I assume there was a good reason why the initial PR #44 already requires 12.

dvkch commented 1 month ago

Indeed the views wouldn't work, but it would allow either make other simpler views inside the app, or just hide the waveform on macOS < 12 but still have the app work on older OSes.

I do realize though that Package.swift doesn't allow for setting platforms differently for each target, and it doesn't seem possible in Swift to import a module only when the required OS version is available. Which means I cannot import DSWaveformImage unless I change my target, but also means you wouldn't be able to importe SwiftUI either, unless you had at least macOS(.v10_15) as a platform, and then make you own view available only starting from macOS 12+.

Maybe I'll just move my deployment target and accept it's getting harder and harder to build for older OSes :)

dmrschmidt commented 1 month ago

The fundamentally challenging thing here is I would say, that when the macOS support got introduced, no older version were supported. Now with the latest release even more of the APIs have moved over to async await and removed other deprecated APIs. I wouldn’t want to bring more conditional checks in.

so one way to add in support would be to branch it off of a previous release. Supporting older versions though, is not really something that is feasible for me maintaining this project.

So that said, my best recommended cause of action for your case is maybe forking an older release yourself and just compiler flagging out what causes problems? The UI is already separated from the Core into separate frameworks, so if you don’t need SwiftUI in all cases, you should be able to conditionally import that part only?

dvkch commented 1 month ago

That is completely understandable. I'll wait for conditional imports in Swift then, it would definitely solve this issue in a couple lines :)