You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+95Lines changed: 95 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -365,6 +365,101 @@ NavigationView {
365
365
}
366
366
```
367
367
368
+
369
+
#### Using with external loaders/caches/coders
370
+
371
+
SDWebImage itself, supports many custom loaders (like [Firebase Storage](https://github.com/firebase/FirebaseUI-iOS) and [PhotosKit](https://github.com/SDWebImage/SDWebImagePhotosPlugin)), caches (like [YYCache](https://github.com/SDWebImage/SDWebImageYYPlugin) and [PINCache](https://github.com/SDWebImage/SDWebImagePINPlugin)), and coders (like [WebP](https://github.com/SDWebImage/SDWebImageWebPCoder) and [AVIF](https://github.com/SDWebImage/SDWebImageAVIFCoder), even [Lottie](https://github.com/SDWebImage/SDWebImageLottieCoder)).
372
+
373
+
Here is the tutorial to setup these external components with SwiftUI environment.
374
+
375
+
##### Setup external SDKs
376
+
377
+
You can put the setup code inside your SwiftUI `App.init()` method.
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
414
+
415
+
var body: some Scene {
416
+
WindowGroup {
417
+
ContentView()
418
+
}
419
+
}
420
+
}
421
+
```
422
+
423
+
##### Use external SDKs
424
+
425
+
For some of custom loaders, you need to create the `URL` struct with some special APIs, so that SDWebImage can retrieve the context from other SDKs, like:
426
+
427
+
+ FirebaseStorage
428
+
429
+
```swift
430
+
let storageRef: StorageReference
431
+
let storageURL = NSURL.sd_URL(with: storageRef) as URL?
432
+
// Or via convenience extension
433
+
let storageURL = storageRef.sd_URLRepresentation
434
+
```
435
+
436
+
+ PhotosKit
437
+
438
+
```swift
439
+
let asset: PHAsset
440
+
let photosURL = NSURL.sd_URL(with: asset) as URL?
441
+
// Or via convenience extension
442
+
let photosURL = asset.sd_URLRepresentation
443
+
```
444
+
445
+
For some of custom coders, you need to request the image with some options to control the behavior, like Vector Images SVG/PDF. Because SwiftUI.Image or WebImage does not supports vector graph at all.
For caches, you actually don't need to worry about anything. It just works after setup.
462
+
368
463
#### Using for backward deployment and weak linking SwiftUI
369
464
370
465
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.
0 commit comments