janmensch/semiliquidglass
You want to make use of Liquid Glass?
Liquid Glass
For details on how to use Liquid Glass itself, please refer to Apple's documentation. This library only provides a mirrored API that is available on pre Liquid Glass OS versions (e.g. iOS 18), so that you can refer to Liquid Glass usage without explicit availability checks all over your code.
Supported operating systems
This library handles the API availability checks for all relevant operating systems:
- [iOS]
- [iPadOS]
- [watchOS]
- [macOS]
- [tvOS]
Goal
The goal of this library is to help teams navigate the duration where apps need to support older OS versions but still want to leverage Liquid Glass when the client supports it. APIs are built in a way that once you raise your deployment target to a Liquid Glass capable OS, you can simply remove the library, remove fallbacks and rename usages of .glassEffectIfAvailable() to .glassEffect().
Documentation
All types, methods and properties carry documentation comments. You can inspect the documentation in Xcode while coding or look it up here on GitHub.
Work in progress
Refer to the issues section of this repo to see what things are being worked on.
Collaboration
Input, suggestions and contributions are welcome. Please feel free to contact me, open an issue or even open a PR to help directly.
Decisions made when building this library
This library tries to make as few assumptions as possible. That is why for example the view modifiers .glassEffectIfAvailable(), .glassEffectIDIfAvailable() and .glassEffectUnionIfAvailable(id:namespace:) don't provide parameters to define fallback behavior.
Reason 1: If there were such parameters, this library would make assumptions on how your app should handle the case that the client is running pre xOS 26. It might be correct for some apps, but not for most. Please define your own fallback behavior via .noGlassAvailable(transform:).
Reason 2: This library wants to be as easy to remove as possible, once you raise your deployment target to xOS 26. Meaning you can search and replace e.g. .glassEffectIfAvailable with .glassEffect through your entire codebase in one go. Just as any place with .noGlassAvailable(transform:) can be removed. If there were fallback parameters, you would need stop and think on every call site.
License
SemiliquidGlass is available under the MIT license. See the LICENSE file for more info.
Package Metadata
Repository: janmensch/semiliquidglass
Default branch: main
README: README.md