flutterfire icon indicating copy to clipboard operation
flutterfire copied to clipboard

[storage] Cannot compile

Open InShad7 opened this issue 1 year ago • 9 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues.

Which plugins are affected?

No response

Which platforms are affected?

iOS

Description

when I run my flutter project on Xcode I get this error

  Swift Compiler Error (Xcode): Implicit use of 'self' in closure; use 'self.' to make capture semantics explicit
/Users/admin/Desktop/munjiya_ios/ios/Pods/FirebaseStorage/FirebaseStorage/Sources/StorageDownloadTask.swift:127
:13


 Swift Compiler Error (Xcode): Reference to property 'pageSize' in closure requires explicit use of 'self' to
 make capture semantics explicit
 /Users/admin/Desktop/munjiya_ios/ios/Pods/FirebaseStorage/FirebaseStorage/Sources/Internal/StorageListTask.swif
 t:94:13


 Swift Compiler Error (Xcode): Reference to property 'previousPageToken' in closure requires explicit use of
 'self' to make capture semantics explicit
 /Users/admin/Desktop/munjiya_ios/ios/Pods/FirebaseStorage/FirebaseStorage/Sources/Internal/StorageListTask.swif
 t:98:13

Could not build the application for the simulator. Error launching application on iPhone 14 Pro.

but in android it works perfectly

Reproducing the issue

these are the file I got errors

    ios/Pods/FirebaseStorage/FirebaseStorage/Sources/Internal/StorageListTask.swift

   ios/Pods/FirebaseStorage/FirebaseStorage/Sources/StorageDownloadTask.swift

Firebase Core version

3.1.0

Flutter Version

3.22.2

Relevant Log Output

Launching lib/main.dart on iPhone 14 Pro in debug mode...
Running pod install...                                            167.1s
Running Xcode build...                                                  
Xcode build done.                                           400.5s
Failed to build iOS app
Swift Compiler Error (Xcode): Implicit use of 'self' in closure; use 'self.' to make capture semantics explicit
/Users/admin/Desktop/munjiya_ios/ios/Pods/FirebaseStorage/FirebaseStorage/Sources/StorageDownloadTask.swift:127
:13


Swift Compiler Error (Xcode): Reference to property 'pageSize' in closure requires explicit use of 'self' to
make capture semantics explicit
/Users/admin/Desktop/munjiya_ios/ios/Pods/FirebaseStorage/FirebaseStorage/Sources/Internal/StorageListTask.swif
t:94:13


Swift Compiler Error (Xcode): Reference to property 'previousPageToken' in closure requires explicit use of
'self' to make capture semantics explicit
/Users/admin/Desktop/munjiya_ios/ios/Pods/FirebaseStorage/FirebaseStorage/Sources/Internal/StorageListTask.swif
t:98:13


Could not build the application for the simulator.
Error launching application on iPhone 14 Pro.

Flutter dependencies

firebase_storage: 12.0.1 firebase_core: 3.1.0 firebase_messaging: 15.0.1

Additional context and comments

No response

InShad7 avatar Jun 15 '24 08:06 InShad7

Hello, which version of XCode are you using?

Lyokone avatar Jun 17 '24 12:06 Lyokone

Xcode 14.2 MacOS 12

InShad7 avatar Jun 18 '24 07:06 InShad7

Hello @InShad7,

Can you upgrade your Xcode to version 15 as per Flutter documentation?

TarekkMA avatar Jun 21 '24 13:06 TarekkMA

hello. did you solve this issue?

Movement83 avatar Jun 25 '24 23:06 Movement83

not by updating the version because i cant be able to update because my macOS version is 12.

but i go through the errors and fix like this

Solution 1: StorageListTask file

   if (self.pageSize != nil) {
        queryParams["maxResults"] = "\(self.pageSize)"
   }

    if (self.previousPageToken != nil) {
        queryParams["pageToken"] = self.previousPageToken
  }

StorageDownloadTask file

 if  (self.fileURL != nil) {
    // Handle file downloads
        fetcher.destinationFileURL = self.fileURL
    fetcher.downloadProgressBlock = { [weak self] (bytesWritten: Int64,
                                                   totalBytesWritten: Int64,
                                                   totalBytesExpectedToWrite: Int64) in
        guard let self = self else { return }
        self.state = .progress
        self.progress.completedUnitCount = totalBytesWritten
        self.progress.totalUnitCount = totalBytesExpectedToWrite
        self.fire(for: .progress, snapshot: self.snapshot)
        self.state = .running
    }
  }

Solution 2:

StorageListTask file

  if let pageSize = self.pageSize {
    queryParams["maxResults"] = "\(pageSize)"
  }

  if let previousPageToken = self.previousPageToken {
    queryParams["pageToken"] = previousPageToken
  }

StorageDownloadTask file

  if let fileURL = self.fileURL {
    // Handle file downloads
    fetcher.destinationFileURL = fileURL
    fetcher.downloadProgressBlock = { [weak self] (bytesWritten: Int64,
                                                   totalBytesWritten: Int64,
                                                   totalBytesExpectedToWrite: Int64) in
        guard let self = self else { return }
        self.state = .progress
        self.progress.completedUnitCount = totalBytesWritten
        self.progress.totalUnitCount = totalBytesExpectedToWrite
        self.fire(for: .progress, snapshot: self.snapshot)
        self.state = .running
    }
  }

after do like this i can build.

InShad7 avatar Jun 26 '24 06:06 InShad7

How about lowering your Firebase storage version? 11.x.x ?

Movement83 avatar Jun 26 '24 07:06 Movement83

Hello @InShad7, Can you delete your Pods/Podlock file and try again?

cd ios
rm -rf Pods && rm Podfile.lock
pod repo update
cd ..
flutter clean && flutter pub get

TarekkMA avatar Jun 26 '24 09:06 TarekkMA

How about lowering your Firebase storage version? 11.x.x ?

when i lowered the version to 11.6.0 then the code comes like this without changing anything in the file and can compile successfully.

StorageListTask

    if let pageSize = self.pageSize {
      queryParams["maxResults"] = "\(pageSize)"
   }

  if let previousPageToken = self.previousPageToken {
     queryParams["pageToken"] = previousPageToken
  }

StorageDownloadTask

if let fileURL = self.fileURL {
// Handle file downloads
fetcher.destinationFileURL = fileURL
fetcher.downloadProgressBlock = { [weak self] (bytesWritten: Int64,
                                               totalBytesWritten: Int64,
                                               totalBytesExpectedToWrite: Int64) in
    guard let self = self else { return }
    self.state = .progress
    self.progress.completedUnitCount = totalBytesWritten
    self.progress.totalUnitCount = totalBytesExpectedToWrite
    self.fire(for: .progress, snapshot: self.snapshot)
    self.state = .running
}

}

InShad7 avatar Jun 26 '24 10:06 InShad7

Hello @InShad7, Can you delete your Pods/Podlock file and try again?

cd ios
rm -rf Pods && rm Podfile.lock
pod repo update
cd ..
flutter clean && flutter pub get

i tried this but wont change anything. After deleted the file and clean when i run pub get then also the same error within the file.

InShad7 avatar Jun 26 '24 10:06 InShad7

You mention that you are on macOS version 12 and thus unable to update to the latest version. Unfortunately, we will not be able to fix this from our side. You can still use an older version of the firebase_storage to test locally and use a CI tool to compile the app.

Lyokone avatar Jul 08 '24 08:07 Lyokone