I'm adding support for LiveActivities/Widgetkit for my iOS app. I'm still supporting older versions for iOS 14+. When checking if the user returned to the app through the LiveActivity in my SceneDelegate:
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
if #available(iOS 16.2, *), isLiveActivity(activity: userActivity) {
...
} else {
let _ = handleDynamicLink(url: userActivity.webpageURL)
}
}
with
@available(iOS 16.2, *)
public func isLiveActivity(activity: NSUserActivity) -> Bool {
return activity.activityType == NSUserActivityTypeLiveActivity
}
Now the issue is no matter how I wrap it in #available(iOS 16.2, *) or even if I don't call isLiveActivity
at all, just the presence of NSUserActivityTypeLiveActivity
in the code anywhere will, on older iOS versions (tested on simulator only) throw the error:
dyld: Symbol not found: _NSUserActivityTypeLiveActivity
How am I supposed to include this check if I can't even include the symbol anywhere in my code ?
I would have assumed NSUserActivityTypeLiveActivity
to be a compile time constant, but it seems like it's dynamically looked up and crashes, since it isn't available in older versions of WidgetKit.