iosswiftflutterpodfileflutter-stripe

Trying to implement stripe in Flutter/iOS and I get errors in all the generated files in Pod, So, I can't even run the app


Swift Compiler Error (Xcode): Missing return in closure expected to return 'String' /Users/mac/Documents/Programming/Projects/yay_food/ios/Pods/StripeCore/StripeCore/StripeCore/Source/Analytics/AnalyticLoggableError.swift:62:8

Swift Compiler Error (Xcode): Missing return in closure expected to return 'String' /Users/mac/Documents/Programming/Projects/yay_food/ios/Pods/StripeCore/StripeCore/StripeCore/Source/Analytics/AnalyticLoggableError.swift:69:8

I have searched everywhere but It doesn't seem like a problem regarding swift cause those are self generated files that stripe has generated for ios.

I tried doing flutter clean and restarting everything, but that didn't work either. I even tried doing on it on a brand new project. Or downgrading stripe. Nothing worked.

and if I overridden the error in the generated class. I get the same error but from a different file.

For Example:

Swift Compiler Error (Xcode): Missing return in closure expected to return 'Bool' /Users/mac/Documents/Programming/Projects/yay_food/ios/Pods/StripePaymentSheet/StripePaymentSheet/StripePaymentSheet/Source/PaymentSheet/ViewControllers/PaymentMethodFormViewController.swift:215:8


Solution

  • I looked at the code on github and the closures uses the new possibility to omit the return keyword in if/else and switch statements.

    This was introduced in Swift 5.9 so the solution here is to update your project to use that version (or newer) of Swift since it seems to be what the Stripe library is built with or downgrade to an earlier version of the library.