ShoutSocial / share_handler

A plugin to facilitate receiving and handling share intents
43 stars 45 forks source link

Swift compile error (...iOS 15.0 or newer...) #33

Open caseycrogers opened 2 years ago

caseycrogers commented 2 years ago

When I try to run my app after following the instructions for iOS, I get a whole slew of errors all with roughly the same message:

Swift Compiler Error (Xcode): 'Task' is only available in application extensions for iOS 15.0 or newer
/Users/caseycrogers/Documents/code/flutter/.pub-cache/hosted/pub.dartlang.org/share_handler_ios-0.0.9/ios/Models/Classes/ShareHandlerIosViewController.swift:60:8

I bumped my deployment target up to iOS 15.0 and tried all the generic XCode debugging steps (Flutter clean, delete pods and reinstall, close XCode and reopen, etc etc) with no luck.

Do you have any idea what I'm doing wrong here and how I might fix it?

caseycrogers commented 2 years ago

I followed XCode's suggestion and just threw @available(iOSApplicationExtension 15.0.0, *) in front of everything and it now appears to work.

This feels too stupid to be a real solution, for example, can someone still attempt to run my app on <15.0? In which case the app will just barf? If you have any advice for me it'd be much appreciated! In the meantime I will proceed with my stupid fix.

JoshJuncker commented 2 years ago

@caseycrogers The Share Extension and your main Runner project can have different target iOS versions. I use swift code in the share extension that requires a higher iOS version. I could rewrite it with older swift syntax / target an older version, but haven't had the appetite to do so as most iOS users update to recent versions really quickly.