I'm having an interesting problem with watchOS 3
and watchOS 2
. In my ComplicationController
I want to support both watchOS 3
and watchOS 2.
When creating the complication templates I'm checking if the user is running watchOS 3
. If he is I will allow an .ExtraLarge
complication to be used, otherwise this option is not available.
I'm using the #available
syntax, but the app fails to even launch on watchOS 2
because of a missing framework. Here is my code:
if #available(watchOSApplicationExtension 3.0, *) {
if complicationFamily == .ExtraLarge {
let extraLarge = CLKComplicationTemplateExtraLargeSimpleText()
extraLarge.textProvider = simpleTextProvider
return extraLarge
} else {
return nil
}
} else {
return nil
}
When I run on watchOS 2
this is the error I get:
dyld: Symbol not found: _OBJC_CLASS_$_CLKComplicationTemplateExtraLargeSimpleText
Referenced from: /Users/asdf/Library/Developer/CoreSimulator/Devices/48D00565-3BA5-4851-B249-5818BA060716/data/Containers/Bundle/Application/1ACF1C41-9D9E-4AB6-9D49-767A067AE968/WatchKit App.app/PlugIns/WatchKit Extension.appex/WatchKit Extension
Expected in: /Library/Developer/CoreSimulator/Profiles/Runtimes/watchOS 2.2.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/ClockKit.framework/ClockKit
Has anyone else had issues deploying to both watchOS 3
and watchOS 2
?
I figured it out with help from a post on the Apple Developer Forums. I needed to add the ClockKit.framework
to the linked binaries and set its status to Optional
. Now everything works as expected on watchOS 2
.
Here's the post: https://forums.developer.apple.com/thread/61712