• Stars
    star
    940
  • Rank 48,627 (Top 1.0 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 2 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

watchOS macOS tvOS ios swift

SwiftUI Backports

Introducing a collection of SwiftUI backports to make your iOS development easier.

Many backports support iOS 13+ but where UIKIt features were introduced in later versions, the same will be applicable to these backports, to keep parity with UIKit.

In some cases, I've also included additional APIs that bring more features to your SwiftUI development.

Note, all backports will be API-matching to Apple's official APIs, any additional features will be provided separately.

All backports are fully documented, in most cases using Apple's own documentation for consistency. Please refer to the header docs or Apple's original documentation for more details.

There is also a Demo project available where you can see full demonstrations of all backports and additional features, including reference code to help you get started.

Lastly, I hope this repo also serves as a great resource for how you can backport effectively with minimal hacks ๐Ÿ‘

Sponsor

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 me as it helps keep me working on useful libraries like these ๐Ÿ˜ฌ

You can also give me a follow and a 'thanks' anytime.

Twitter

Usage

The library adopts a backport design by Dave DeLong that makes use of a single type to improve discoverability and maintainability when the time comes to remove your backport implementations, in favour of official APIs.

Backports of pure types, can easily be discovered under the Backport namespace. Similarly, modifiers are discoverable under the .backport namespace.

Unfortunately Environment backports cannot be access this way, in those cases the Apple API values will be prefixed with backport to simplify discovery.

Types:

@Backport.AppStorage("filter-enabled")
private var filterEnabled: Bool = false

Modifier:

Button("Show Prompt") {
    showPrompt = true
}
.sheet(isPresented: $showPrompt) {
    Prompt()
        .backport.presentationDetents([.medium, .large])
}

Environment:

@Environment(\.backportRefresh) private var refreshAction

Backports

SwiftUI

  • AsyncImage
  • AppStorage
  • background โ€“ ViewBuilder API
  • DismissAction
  • DynamicTypeSize โ€“ Label โ€“ LabeledContent
  • NavigationDestination โ€“ uses a standard NavigationView
  • navigationTitle โ€“ newer API
  • overlay โ€“ ViewBuilder API
  • onChange
  • openURL
  • ProgressView
  • presentationDetents
  • presentationDragIndicator
  • quicklookPreview
  • requestReview
  • Refreshable โ€“ includes pull-to-refreshย 
  • ScaledMetric
  • ShareLink
  • StateObject
  • scrollDisabled
  • scrollDismissesKeyboard
  • scrollIndicators
  • Section(_ header:)
  • task โ€“ async/await modifier

UIKit

  • UIHostingConfiguration โ€“ simplifies embedding SwiftUI in UICollectionViewCell and UITableViewCell

Extras

Modal Presentations

Adding this to your presented view, you can use the provided closure to present an ActionSheet to a user when they attempt to dismiss interactively. You can also use this to disable interactive dismissals entirely.

presentation(isModal: true) { /* attempt */ }

FittingGeometryReader

A custom GeometryReader implementation that correctly auto-sizes itself to its content. This is useful in many cases where you need a GeometryReader but don't want it to implicitly take up its parent View's bounds.

FittingScrollView

A custom ScrollView that respects Spacer's when the content is not scrollable. This is useful when you need to place a view at the edges of your scrollview while its content is small enough to not require scrolling. Another great use case is vertically centered content that becomes top aligned once the content requires scrolling.

Installation

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"))

More Repositories

1

Peek

All new design. Inspect your iOS application at runtime.
Swift
2,601
star
2

InkKit

Drawing and Geometry made easy on iOS - now in Swift 3.0
Swift
373
star
3

iMessageStyleReveal

Adds iMessage style timestamp support. Written in Swift!
Swift
147
star
4

MarkdownText

A native SwiftUI view for rendering Markdown text in an iOS or macOS app
Swift
142
star
5

GraphicsRenderer

A drop-in UIGraphicsRenderer port -- CrossPlatform, Swift 4, Image & PDF
Swift
109
star
6

Warrant

Data validation made easy. In code and from Interface Builder.
Swift
54
star
7

Stack

A Type-Safe, Thread-Safe-ish approach to CoreData in Swift
Swift
48
star
8

SwiftUIPlus

SwiftUI additions and helpers that are missing from the official implementation.
Swift
24
star
9

Color

A Swifty type-safe abstraction around color models
Objective-C
23
star
10

Feedback

Familiar, easy state-driven haptics, audio and more
Swift
22
star
11

ColumnView

A column-view navigation controller that behaves similarly to Files and Finder
Swift
21
star
12

Logging

Apple's SwiftLog + OSLog style StringInterpolation
Swift
16
star
13

Objective-C-Style-Guide

Objective-C Style Guide
15
star
14

SwiftUIBackportsDemo

A collection of Demo's for the SwiftUI Backports.
Swift
15
star
15

SwiftBackports

A collection of Swift backports for earlier versions of iOS, macOS, tvOS and watchOS
Swift
13
star
16

Abracadabra

A truly plug 'n' play solution for securing your code.
Objective-C
12
star
17

Snaply

Drop-in snapping behaviour for any scroll/collection/table/view using arbitrary points!
Swift
9
star
18

CornerMasking

SPXMasking is category on CALayer that allows you to specify different a corner radius for each corner of a CALayer.
Objective-C
8
star
19

MarkdownTextDemo

A demo app for showcasing the MarkdownText library.
Swift
7
star
20

SVGRenderer

An SVG renderer using the familiar GraphicsRenderer API.
Swift
6
star
21

ActivityView

Moved to SwiftUI-Plus/ActivityView
5
star
22

Storage

Moved to SwiftUI-Plus/DefaultStorage
5
star
23

Media

Moved to SwiftUI-Plus/Media
5
star
24

ghost-app-extract

Allows you to create better excerpt's in your Ghost blog posts.
JavaScript
4
star
25

AppManifest

Swift
4
star
26

SwiftLayout

A Swift library for programmatically dealing with AutoLayout
Swift
4
star
27

FlowLayout-Demo

A high-performance flow layout that provides global headers, footers, section backgrounds and various configurations.
Swift
4
star
28

Endpoints

A generic Swift networking library inspired by SwiftUI APIs
Swift
4
star
29

Analytics

Swift
3
star
30

PhotoLibrary

Photo library picker for iOS
Swift
2
star
31

primo

The first script to install a newly installed Mac! This will install common terminal utilities & applications.
Shell
2
star
32

Whos-Who

Who's Who sample code for job interview.
Objective-C
2
star
33

SPXLayout

AutoLayout the programmatic way
Objective-C
2
star
34

SPXSubscripting

This is a library for adding subscripting support to various Foundation classes. It also adds some interesting solutions to working with NSString's, NSAttributedString's and their attributes.
Objective-C
2
star
35

SPXDataSources

DataSource implementations for UITableView and UICollection, plus more...
Objective-C
2
star
36

Populate

Data providers for populating your data views.
Swift
2
star
37

bash

Various bash scripts I've written to simply my development and sometimes just to make me smile.
Shell
2
star
38

DownloadService

A Swift service for handling downloads and their associated resources.
Swift
1
star
39

SwiftHelpDemo

A demo project for showcasing SwiftHelp
Swift
1
star
40

SwiftHelp

A SwiftUI library for building interactive help systems in your apps
Swift
1
star
41

Development-Environment

All files, settings and configurations I use for my Development Environment's
1
star
42

FlowLayout

A high-performance flow layout that provides global headers, footers, section backgrounds and various configurations.
Swift
1
star
43

SPXCacheManager

A highly configurable and reusable library for handling caching in your iOS apps. Not only for images!!
Objective-C
1
star
44

SPXKeychain

My iOS Keychain Wrapper
Objective-C
1
star
45

PGTest-XCTest

Swift
1
star
46

ScaledMetric

A SwiftUI dynamic property wrapper (a back-port) that scales a numeric value. iOS, macOS, tvOS, watchOS
Swift
1
star
47

Snippex

My own personal library of reusable code that compiles and standardises some classes across iOS and OSX.
Objective-C
1
star
48

CellProvider

A generic cell provider implementation in Swift
Shell
1
star