I added widget target in my app, and I tried to the iOS 14 and newer condition for that, but I still got this error:
'main()' is only available in application extensions for iOS 14.0 or newer
@available(iOSApplicationExtension 14.0, *)
@main
struct Widget: SwiftUI.Widget {
let kind: String = "Widget"
var body: some WidgetConfiguration {
IntentConfiguration(kind: kind, intent: ConfigurationIntent.self, provider: Provider()) { entry in
WidgetEntryView(entry: entry)
}
.configurationDisplayName("My Widget")
.description("This is an example widget.")
}
}
That @available is the one that Xcode suggested me
Could anyone help me on that?
In the file where your put '@main', look at the target membership on the right sidebar, remove your main app as a target and leave your widget extension.
If you added or already had an extension you should check that the deployment info for you extension is 14.0.
See screenshot: enter image description here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With