Skip to content

Commit e29e0b9

Browse files
committed
Merge branch 'master' of https://github.com/SDWebImage/SDWebImageSwiftUI into feature/visionOS
2 parents 2c24b7f + 5622af5 commit e29e0b9

24 files changed

+108
-907
lines changed

Example/SDWebImageSwiftUI.xcodeproj/project.pbxproj

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,16 @@
1313
320CDC3222FADB45007CF858 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 320CDC3122FADB45007CF858 /* Assets.xcassets */; };
1414
320CDC3522FADB45007CF858 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 320CDC3422FADB45007CF858 /* Preview Assets.xcassets */; };
1515
320CDC3822FADB45007CF858 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 320CDC3622FADB45007CF858 /* LaunchScreen.storyboard */; };
16-
322E0DF728D331A20003A55F /* IndicatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 322E0DF028D331A20003A55F /* IndicatorTests.swift */; };
1716
322E0DF828D331A20003A55F /* WebImageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 322E0DF128D331A20003A55F /* WebImageTests.swift */; };
1817
322E0DF928D331A20003A55F /* Images.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 322E0DF228D331A20003A55F /* Images.bundle */; };
1918
322E0DFA28D331A20003A55F /* ImageManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 322E0DF328D331A20003A55F /* ImageManagerTests.swift */; };
2019
322E0DFB28D331A20003A55F /* AnimatedImageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 322E0DF428D331A20003A55F /* AnimatedImageTests.swift */; };
2120
322E0DFD28D331A20003A55F /* TestUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 322E0DF628D331A20003A55F /* TestUtils.swift */; };
2221
322E0E1828D3320D0003A55F /* ImageManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 322E0DF328D331A20003A55F /* ImageManagerTests.swift */; };
23-
322E0E1928D3320D0003A55F /* IndicatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 322E0DF028D331A20003A55F /* IndicatorTests.swift */; };
2422
322E0E1A28D3320D0003A55F /* WebImageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 322E0DF128D331A20003A55F /* WebImageTests.swift */; };
2523
322E0E1B28D3320D0003A55F /* AnimatedImageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 322E0DF428D331A20003A55F /* AnimatedImageTests.swift */; };
2624
322E0E1C28D3320D0003A55F /* TestUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 322E0DF628D331A20003A55F /* TestUtils.swift */; };
2725
322E0E1D28D3320D0003A55F /* ImageManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 322E0DF328D331A20003A55F /* ImageManagerTests.swift */; };
28-
322E0E1E28D3320D0003A55F /* IndicatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 322E0DF028D331A20003A55F /* IndicatorTests.swift */; };
2926
322E0E1F28D3320D0003A55F /* WebImageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 322E0DF128D331A20003A55F /* WebImageTests.swift */; };
3027
322E0E2028D3320D0003A55F /* AnimatedImageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 322E0DF428D331A20003A55F /* AnimatedImageTests.swift */; };
3128
322E0E2128D3320D0003A55F /* TestUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 322E0DF628D331A20003A55F /* TestUtils.swift */; };
@@ -145,7 +142,6 @@
145142
320CDC3722FADB45007CF858 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
146143
320CDC3922FADB45007CF858 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
147144
322E0DE628D3318B0003A55F /* SDWebImageSwiftUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SDWebImageSwiftUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
148-
322E0DF028D331A20003A55F /* IndicatorTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IndicatorTests.swift; sourceTree = "<group>"; };
149145
322E0DF128D331A20003A55F /* WebImageTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebImageTests.swift; sourceTree = "<group>"; };
150146
322E0DF228D331A20003A55F /* Images.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Images.bundle; sourceTree = "<group>"; };
151147
322E0DF328D331A20003A55F /* ImageManagerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageManagerTests.swift; sourceTree = "<group>"; };
@@ -300,7 +296,6 @@
300296
322E0DEF28D331A20003A55F /* Tests */ = {
301297
isa = PBXGroup;
302298
children = (
303-
322E0DF028D331A20003A55F /* IndicatorTests.swift */,
304299
322E0DF128D331A20003A55F /* WebImageTests.swift */,
305300
322E0DF228D331A20003A55F /* Images.bundle */,
306301
322E0DF328D331A20003A55F /* ImageManagerTests.swift */,
@@ -855,7 +850,6 @@
855850
322E0DF828D331A20003A55F /* WebImageTests.swift in Sources */,
856851
322E0DFD28D331A20003A55F /* TestUtils.swift in Sources */,
857852
322E0DFB28D331A20003A55F /* AnimatedImageTests.swift in Sources */,
858-
322E0DF728D331A20003A55F /* IndicatorTests.swift in Sources */,
859853
322E0DFA28D331A20003A55F /* ImageManagerTests.swift in Sources */,
860854
);
861855
runOnlyForDeploymentPostprocessing = 0;
@@ -868,7 +862,6 @@
868862
322E0E1A28D3320D0003A55F /* WebImageTests.swift in Sources */,
869863
322E0E1828D3320D0003A55F /* ImageManagerTests.swift in Sources */,
870864
322E0E1C28D3320D0003A55F /* TestUtils.swift in Sources */,
871-
322E0E1928D3320D0003A55F /* IndicatorTests.swift in Sources */,
872865
);
873866
runOnlyForDeploymentPostprocessing = 0;
874867
};
@@ -880,7 +873,6 @@
880873
322E0E1F28D3320D0003A55F /* WebImageTests.swift in Sources */,
881874
322E0E1D28D3320D0003A55F /* ImageManagerTests.swift in Sources */,
882875
322E0E2128D3320D0003A55F /* TestUtils.swift in Sources */,
883-
322E0E1E28D3320D0003A55F /* IndicatorTests.swift in Sources */,
884876
);
885877
runOnlyForDeploymentPostprocessing = 0;
886878
};

Example/SDWebImageSwiftUIDemo/ContentView.swift

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,6 @@ class UserSettings: ObservableObject {
1717
#endif
1818
}
1919

20-
#if os(watchOS)
21-
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
22-
extension Indicator where T == ProgressView<EmptyView, EmptyView> {
23-
static var activity: Indicator {
24-
Indicator { isAnimating, progress in
25-
ProgressView()
26-
}
27-
}
28-
29-
static var progress: Indicator {
30-
Indicator { isAnimating, progress in
31-
ProgressView(value: progress.wrappedValue)
32-
}
33-
}
34-
}
35-
#endif
36-
3720
// Test Switching url using @State
3821
struct ContentView2: View {
3922
@State var imageURLs = [

Example/SDWebImageSwiftUIDemo/DetailView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ struct DetailView: View {
111111
WebImage(url: URL(string:url), options: [.progressiveLoad, .delayPlaceholder], isAnimating: $isAnimating)
112112
.resizable()
113113
.placeholder(.wifiExclamationmark)
114-
.indicator(.progress)
114+
.indicator(.progress(style: .circular))
115115
.scaledToFit()
116116
}
117117
}

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// swift-tools-version:5.2
1+
// swift-tools-version:5.3
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
55

66
let package = Package(
77
name: "SDWebImageSwiftUI",
88
platforms: [
9-
.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6)
9+
.macOS(.v11), .iOS(.v14), .tvOS(.v14), .watchOS(.v7)
1010
],
1111
products: [
1212
// Products define the executables and libraries produced by a package, and make them visible to other packages.

README.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ All issue reports, feature requests, contributions, and GitHub stars are welcome
5959
## Requirements
6060

6161
+ Xcode 12+
62-
+ iOS 13+ (14+ Recommended)
63-
+ macOS 10.15+ (11+ Recommended)
64-
+ tvOS 13+ (14+ Recommended)
65-
+ watchOS 6+ (7+ Recommended)
62+
+ iOS 14+
63+
+ macOS 11+
64+
+ tvOS 14+
65+
+ watchOS 7+
6666

6767
## SwiftUI 2.0 Compatibility
6868

@@ -82,9 +82,7 @@ var body: some View {
8282
}
8383
```
8484

85-
Note: However, many differences behavior between iOS 13/14's is hard to fixup. And we may break some APIs (which are not designed to be public) to fixup it.
86-
87-
Due to maintain issue, in the future release, we will drop the iOS 13 supports and always match SwiftUI 2.0's behavior. And **v2.x** may be the last version support iOS 13.
85+
Note: However, many differences behavior between iOS 13/14 is hard to fixup. Due to maintain issue, from SDWebImageSwiftUI v3.0, iOS 13 is no longer supported. We always match SwiftUI 2.0's behavior.
8886

8987

9088
## Installation
@@ -174,7 +172,14 @@ var body: some View {
174172
}
175173
```
176174

177-
Note: For indicator, you can custom your own as well. For example, iOS 14/watchOS 7 introduce the new `ProgressView`, which can replace our built-in `ProgressIndicator/ActivityIndicator` (where watchOS does not provide).
175+
Note: For indicator, you can custom your own as well. For example, iOS 14/watchOS 7 introduce the new `ProgressView`, which can be easily used via:
176+
177+
```swift
178+
WebImage(url: url)
179+
.indicator(.activity)
180+
```
181+
182+
or you can just write like:
178183

179184
```swift
180185
WebImage(url: url)
@@ -522,7 +527,7 @@ For caches, you actually don't need to worry about anything. It just works after
522527

523528
#### Using for backward deployment and weak linking SwiftUI
524529

525-
SDWebImageSwiftUI supports to use when your App Target has a deployment target version less than iOS 13/macOS 10.15/tvOS 13/watchOS 6. Which will weak linking of SwiftUI(Combine) to allows writing code with available check at runtime.
530+
SDWebImageSwiftUI supports to use when your App Target has a deployment target version less than iOS 14/macOS 11/tvOS 14/watchOS 7. Which will weak linking of SwiftUI(Combine) to allows writing code with available check at runtime.
526531

527532
To use backward deployment, you have to do the follow things:
528533

@@ -536,7 +541,7 @@ You should notice that all the third party SwiftUI frameworks should have this b
536541

537542
For deployment target version below iOS 12.2 (The first version which Swift 5 Runtime bundled in iOS system), you have to change the min deployment target version of SDWebImageSwiftUI. This may take some side effect on compiler's optimization and trigger massive warnings for some frameworks.
538543

539-
However, for iOS 12.2+, you can still keep the min deployment target version to iOS 13, no extra warnings or performance slow down for iOS 13 client.
544+
However, for iOS 12.2+, you can still keep the min deployment target version to iOS 14, no extra warnings or performance slow down for iOS 14 client.
540545

541546
Because Swift use the min deployment target version to detect whether to link the App bundled Swift runtime, or the System built-in one (`/usr/lib/swift/libswiftCore.dylib`).
542547

@@ -563,7 +568,7 @@ end
563568
+ For CocoaPods user, you can skip the platform version validation in Podfile with:
564569

565570
```ruby
566-
platform :ios, '13.0' # This does not effect your App Target's deployment target version, just a hint for CocoaPods
571+
platform :ios, '14.0' # This does not effect your App Target's deployment target version, just a hint for CocoaPods
567572
```
568573

569574
+ For SwiftPM user, SwiftPM does not support weak linking nor Library Evolution, so it can not deployment to iOS 12+ user without changing the min deployment target.
@@ -576,7 +581,7 @@ Add **all the SwiftUI code** with the available annotation and runtime check, li
576581
// AppDelegate.swift
577582
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
578583
// ...
579-
if #available(iOS 13, *) {
584+
if #available(iOS 14, *) {
580585
window.rootViewController = UIHostingController(rootView: ContentView())
581586
} else {
582587
window.rootViewController = ViewController()
@@ -598,11 +603,11 @@ class ViewController: UIViewController {
598603
}
599604

600605
// ContentView.swift
601-
@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
606+
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
602607
struct ContentView : View {
603608
var body: some View {
604609
Group {
605-
Text("Hello World iOS 13!")
610+
Text("Hello World iOS 14!")
606611
WebImage(url: URL(string: "https://i.loli.net/2019/09/24/rX2RkVWeGKIuJvc.jpg"))
607612
}
608613
}
@@ -638,7 +643,7 @@ SDWebImageSwiftUI has Unit Test to increase code quality. For SwiftUI, there are
638643

639644
However, since SwiftUI is State-Based and Attributed-Implemented layout system, there are open source projects who provide the solution:
640645

641-
+ [ViewInspector](https://github.com/nalexn/ViewInspector): Inspect View's runtime attribute value (like `.frame` modifier, `.image` value). We use this to test `AnimatedImage` and `WebImage`. It also allows the inspect to native UIView/NSView, which we use to test `ActivityIndicator` and `ProgressIndicator`.
646+
+ [ViewInspector](https://github.com/nalexn/ViewInspector): Inspect View's runtime attribute value (like `.frame` modifier, `.image` value). We use this to test `AnimatedImage` and `WebImage`. It also allows the inspect to native UIView/NSView.
642647

643648
To run the test:
644649

SDWebImageSwiftUI.podspec

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ It brings all your favorite features from SDWebImage, like async image loading,
2121
s.author = { 'DreamPiggy' => 'lizhuoli1126@126.com' }
2222
s.source = { :git => 'https://github.com/SDWebImage/SDWebImageSwiftUI.git', :tag => s.version.to_s }
2323

24-
s.ios.deployment_target = '13.0'
25-
s.osx.deployment_target = '10.15'
26-
s.tvos.deployment_target = '13.0'
27-
s.watchos.deployment_target = '6.0'
24+
s.ios.deployment_target = '14.0'
25+
s.osx.deployment_target = '11.0'
26+
s.tvos.deployment_target = '14.0'
27+
s.watchos.deployment_target = '7.0'
2828

2929
s.source_files = 'SDWebImageSwiftUI/Classes/**/*', 'SDWebImageSwiftUI/Module/*.h'
3030
s.pod_target_xcconfig = {
@@ -34,5 +34,5 @@ It brings all your favorite features from SDWebImage, like async image loading,
3434

3535
s.weak_frameworks = 'SwiftUI', 'Combine'
3636
s.dependency 'SDWebImage', '~> 5.10'
37-
s.swift_version = '5.2'
37+
s.swift_version = '5.3'
3838
end

0 commit comments

Comments
 (0)