Skip to content

feat: add FirebaseStorageUISwift product for Swift SPM clients, fix(FirebaseStorageUI): prevent crash with .progressiveLoad on Firebase Storage 9+#1351

Merged
demolaf merged 1 commit into
mainfrom
feat/storage-ui-swift-spm
Jun 11, 2026
Merged

feat: add FirebaseStorageUISwift product for Swift SPM clients, fix(FirebaseStorageUI): prevent crash with .progressiveLoad on Firebase Storage 9+#1351
demolaf merged 1 commit into
mainfrom
feat/storage-ui-swift-spm

Conversation

@demolaf

@demolaf demolaf commented Jun 9, 2026

Copy link
Copy Markdown
Member

Closes #1146
Closes #1114

Fix 1:
Swift SPM clients currently can't call sd_setImage(with:) passing a StorageReference — the ObjC headers use @class forward declarations (required to fix the Clang scan-phase failure in #1350), which leaves StorageReference opaque to the Swift importer.

This PR adds FirebaseStorageUISwift, a new Swift-only SPM library product that bridges this gap by providing properly-typed Swift extensions on UIImageView.

Also migrates FirebaseUI-demo-swift from CocoaPods to SPM and updates StorageViewController to demonstrate the new API.

Fix 2
FIRStorageDownloadTask.fetcher was an internal property removed in Firebase Storage 9.0.0. Accessing it via the progress observer caused a crash when .progressiveLoad was passed as an option.

Guard with respondsToSelector: so the progressive decode path is skipped on Firebase 9+. Images still load to completion — only the in-flight progressive rendering is lost, since Firebase no longer exposes partial download data publicly.

New product

Add FirebaseStorageUISwift to your SPM dependencies and import FirebaseStorageUISwift. This re-exports both FirebaseStorageUI and FirebaseStorage, so no additional imports are needed.

API Changes

extension UIImageView {

  // Without progress — trailing closure resolves to completion
  public func sd_setImageWithStorageReference(
    _ storageRef: StorageReference,
    maxImageSize size: UInt64? = nil,
    placeholderImage placeholder: UIImage? = nil,
    options: SDWebImageOptions = [],
    context: [SDWebImageContextOption: Any]? = nil,
    completion: ((UIImage?, Error?, SDImageCacheType, StorageReference) -> Void)? = nil
  )

  // With progress
  public func sd_setImageWithStorageReference(
    _ storageRef: StorageReference,
    maxImageSize size: UInt64? = nil,
    placeholderImage placeholder: UIImage? = nil,
    options: SDWebImageOptions = [],
    context: [SDWebImageContextOption: Any]? = nil,
    progress: ((Int, Int, StorageReference) -> Void)?,
    completion: ((UIImage?, Error?, SDImageCacheType, StorageReference) -> Void)? = nil
  )
}

@demolaf demolaf changed the base branch from main to fix/storage-ui-spm-firebase-11 June 9, 2026 15:52
@demolaf demolaf marked this pull request as draft June 9, 2026 15:52
gemini-code-assist[bot]

This comment was marked as outdated.

@demolaf demolaf marked this pull request as ready for review June 9, 2026 16:04
@demolaf demolaf marked this pull request as draft June 9, 2026 16:04
@demolaf demolaf changed the title feat(FirebaseStorageUI): add FirebaseStorageUISwift SPM product for Swift-typed API feat: add FirebaseStorageUISwift product for Swift SPM clients Jun 10, 2026
@demolaf demolaf marked this pull request as ready for review June 10, 2026 11:15
@demolaf demolaf force-pushed the fix/storage-ui-spm-firebase-11 branch from f5778a6 to 0272a43 Compare June 10, 2026 12:49
@demolaf demolaf changed the base branch from fix/storage-ui-spm-firebase-11 to main June 10, 2026 13:12
@demolaf demolaf force-pushed the feat/storage-ui-swift-spm branch 3 times, most recently from 7f14c66 to 81e5e29 Compare June 10, 2026 19:39
@demolaf demolaf force-pushed the feat/storage-ui-swift-spm branch from 81e5e29 to cc85959 Compare June 10, 2026 19:41
@demolaf demolaf merged commit 9e62d29 into main Jun 11, 2026
24 checks passed
@demolaf demolaf deleted the feat/storage-ui-swift-spm branch June 11, 2026 09:01
@demolaf demolaf changed the title feat: add FirebaseStorageUISwift product for Swift SPM clients feat: add FirebaseStorageUISwift product for Swift SPM clients, fix(FirebaseStorageUI): prevent crash with .progressiveLoad on Firebase Storage 9+ Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants