Skip to content
Back to search

SwiftUIBackports

A collection of SwiftUI backports for iOS, macOS, tvOS and watchOS

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/shaps80--swiftuibackports/badge.svg)](/listings/shaps80--swiftuibackports)

HTML

<a href="/listings/shaps80--swiftuibackports"><img src="/api/listings/shaps80--swiftuibackports/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

You can install manually (by copying the files in the `Sources` directory) or using Swift Package Manager (**preferred**)

To install using Swift Package Manager, add this to the `dependencies` section of your `Package.swift` file:

`.package(url: "https://github.com/shaps80/SwiftUIBackports.git", .upToNextMajor(from: "2.0.0"))`

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 95 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. ![watchOS](https://img.shields.io/badge/watchOS-DE1F51)
  2. ![macOS](https://img.shields.io/badge/macOS-EE751F)
  3. ![tvOS](https://img.shields.io/badge/tvOS-00B9BB)
  4. ![ios](https://img.shields.io/badge/iOS-0C62C7)
  5. [![swift](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fshaps80%2FSwiftUIBackports%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/shaps80/SwiftUIBackports)
  6. # SwiftUI Backports
  7. Use modern SwiftUI APIs while still supporting older Apple platforms.
  8. SwiftUIBackports mirrors Apple's SwiftUI API names, shapes, behavior, documentation, and availability where practical. This keeps app code familiar today, and easy to migrate away from once your deployment target reaches the native API.
  9. Backports are discovered through `.backport`, the `Backport` namespace, or `backport`-prefixed environment values. The package also includes a machine-readable index and agent skill to help developers and coding agents find the right compatibility API quickly.
  10. Additional APIs, when present, are kept separate from Apple API-matching backports.
  11. This repo can also serve as a reference for building practical SwiftUI backports with minimal hacks.
  12. > [!CAUTION]
  13. > From v27, SwiftUIBackports will require iOS 15+, macOS 12+, tvOS 15+, and watchOS 8+. If you need to support older platform versions, remain on 26.x.
  14. > [!NOTE]
  15. > Using an agent? Install the bundled discovery skill so coding agents can find available backports automatically:
  16. >
  17. > ```sh
  18. > npx skills add shaps80/SwiftUIBackports
  19. > ```
  20. ## Sponsor
  21. Building useful libraries like these, takes time away from my family. I build these tools in my spare time because I feel its important to give back to the community. Please consider [Sponsoring](https://github.com/sponsors/shaps80) me as it helps keep me working on useful libraries like these 😬
  22. You can also give me a follow and a 'thanks' anytime.
  23. [![Twitter](https://img.shields.io/badge/Twitter-@shaps-4AC71B)](http://twitter.com/shaps)
  24. ## Usage
  25. SwiftUIBackports mirrors Apple's SwiftUI APIs where practical, while keeping backported APIs easy to find and remove once your deployment target reaches the native API.
  26. View modifiers are available from `.backport`:
  27. ```swift
  28. sheetContent
  29. .backport.presentationDetents([.medium, .large])
  30. ```
  31. Backported types are usually available from the `Backport` namespace:
  32. ```swift
  33. Backport.LabeledContent("", value: 0)
  34. ```
  35. If the compiler needs the fully-qualified namespace, use `Backport<Any>`:
  36. ```swift
  37. Backport<Any>.LabeledContent("", value: 0)
  38. ```
  39. Environment backports use a `backport` prefix:
  40. ```swift
  41. @Environment(\.backportRequestReview) private var requestReview
  42. ```
  43. ## Backports
  44. The supported backports are indexed in:
  45. ```text
  46. skills/swiftui-backports/references/Backports.jsonl
  47. ```
  48. The line-oriented index lists implemented backports, their kind, source location, and platform availability. Prefer this index over static README examples, which get stale quickly.
  49. This repository also includes an agent skill:
  50. ```text
  51. skills/swiftui-backports/SKILL.md
  52. ```
  53. Use that skill when working in an app that targets older Apple OS versions, or when a compiler availability error blocks use of a newer SwiftUI API. The skill tells agents to:
  54. - check the project deployment target
  55. - search the bundled backport index
  56. - prefer native SwiftUI when the deployment target is new enough
  57. - use `.backport`, `Backport`, or `backport` environment keys when a matching backport exists
  58. ## Installation
  59. You can install manually (by copying the files in the `Sources` directory) or using Swift Package Manager (**preferred**)
  60. To install using Swift Package Manager, add this to the `dependencies` section of your `Package.swift` file:
  61. `.package(url: "https://github.com/shaps80/SwiftUIBackports.git", .upToNextMajor(from: "2.0.0"))`

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.