Наблюдайте, что Сложность вызывает сбой с dyld: Символ не найден: _OBJC_CLASS _ $ _ CLKFullColorImageProvider - PullRequest
0 голосов
/ 26 октября 2018

Я получаю эту ошибку dyld: Symbol not found: _OBJC_CLASS_$_CLKFullColorImageProvider в watchOS 4, но не в watchOS 5, я думаю, что это связано с моим кодом усложнения ниже, но не могу понять, почему ... насколько я могу сказать, компилятор не должен 'не могу искать CLKFullColorImageProvider, поскольку я заблокировал это с помощью if #available(watchOSApplicationExtension 5.0, *)

class Complication: NSObject, CLKComplicationDataSource {
    func getCurrentTimelineEntry(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimelineEntry?) -> Void) {
        if #available(watchOSApplicationExtension 5.0, *) {
            if complication.family == .circularSmall {

                let template = CLKComplicationTemplateCircularSmallRingImage()
                guard let image = UIImage(named: "Circular") else { handler(nil); return}
                template.imageProvider = CLKImageProvider(onePieceImage: image)
                let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
                handler(timelineEntry)

            } else if complication.family == .utilitarianSmall {

                let template = CLKComplicationTemplateUtilitarianSmallRingImage()
                guard let image = UIImage(named: "Utilitarian") else { handler(nil); return}
                template.imageProvider = CLKImageProvider(onePieceImage: image)
                let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
                handler(timelineEntry)

            } else if complication.family == .modularSmall {

                let template = CLKComplicationTemplateModularSmallRingImage()
                guard let image = UIImage(named: "Modular") else { handler(nil); return}
                template.imageProvider = CLKImageProvider(onePieceImage: image)
                let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
                handler(timelineEntry)

            } else if complication.family == .graphicCircular {
                let template = CLKComplicationTemplateGraphicCircularImage()
                guard let image = UIImage(named: "GraphicCircular") else { handler(nil); return}
                template.imageProvider = CLKFullColorImageProvider(fullColorImage: image)
                let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
                handler(timelineEntry)

            } else if complication.family == .graphicBezel {
                let template = CLKComplicationTemplateModularSmallRingImage()
                guard let image = UIImage(named: "GraphicBezel") else { handler(nil); return}
                template.imageProvider = CLKImageProvider(onePieceImage: image)
                let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
                handler(timelineEntry)

            } else if complication.family == .graphicCorner {
                let template = CLKComplicationTemplateGraphicCornerCircularImage()
                guard let image = UIImage(named: "GraphicCorner") else { handler(nil); return}
                template.imageProvider = CLKFullColorImageProvider(fullColorImage: image)
                let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
                handler(timelineEntry)

            } else {

                handler(nil)

            }
        } else {

            if complication.family == .circularSmall {

                let template = CLKComplicationTemplateCircularSmallRingImage()
                guard let image = UIImage(named: "Circular") else { handler(nil); return}
                template.imageProvider = CLKImageProvider(onePieceImage: image)
                let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
                handler(timelineEntry)

            } else if complication.family == .utilitarianSmall {

                let template = CLKComplicationTemplateUtilitarianSmallRingImage()
                guard let image = UIImage(named: "Utilitarian") else { handler(nil); return}
                template.imageProvider = CLKImageProvider(onePieceImage: image)
                let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
                handler(timelineEntry)

            } else if complication.family == .modularSmall {

                let template = CLKComplicationTemplateModularSmallRingImage()
                guard let image = UIImage(named: "Modular") else { handler(nil); return}
                template.imageProvider = CLKImageProvider(onePieceImage: image)
                let timelineEntry = CLKComplicationTimelineEntry(date: Date(), complicationTemplate: template)
                handler(timelineEntry)

            } else {

                handler(nil)

            }
        }
    }

    func getSupportedTimeTravelDirections(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTimeTravelDirections) -> Void) {
        handler([])
    }
    func getLocalizableSampleTemplate(for complication: CLKComplication, withHandler handler: @escaping (CLKComplicationTemplate?) -> Void) {
        if #available(watchOSApplicationExtension 5.0, *) {
            if complication.family == .circularSmall {

                let template = CLKComplicationTemplateCircularSmallRingImage()
                guard let image = UIImage(named: "Circular") else { handler(nil); return}
                template.imageProvider = CLKImageProvider(onePieceImage: image)
                handler(template)

            } else if complication.family == .utilitarianSmall {

                let template = CLKComplicationTemplateUtilitarianSmallRingImage()
                guard let image = UIImage(named: "Utilitarian") else { handler(nil); return}
                template.imageProvider = CLKImageProvider(onePieceImage: image)
                handler(template)

            } else if complication.family == .modularSmall {

                let template = CLKComplicationTemplateModularSmallRingImage()
                guard let image = UIImage(named: "Modular") else { handler(nil); return}
                template.imageProvider = CLKImageProvider(onePieceImage: image)
                handler(template)

            } else if complication.family == .graphicCircular {
                let template = CLKComplicationTemplateGraphicCircularImage()
                guard let image = UIImage(named: "GraphicCircular") else { handler(nil); return}
                template.imageProvider = CLKFullColorImageProvider(fullColorImage: image)
                handler(template)

            } else if complication.family == .graphicBezel {
                let template = CLKComplicationTemplateModularSmallRingImage()
                guard let image = UIImage(named: "GraphicBezel") else { handler(nil); return}
                template.imageProvider = CLKImageProvider(onePieceImage: image)
                handler(template)

            } else if complication.family == .graphicCorner {
                let template = CLKComplicationTemplateGraphicCornerCircularImage()
                guard let image = UIImage(named: "GraphicCorner") else { handler(nil); return}
                template.imageProvider = CLKFullColorImageProvider(fullColorImage: image)
                handler(template)

            } else {

                handler(nil)

            }
        } else {
            if complication.family == .circularSmall {

                let template = CLKComplicationTemplateCircularSmallRingImage()
                guard let image = UIImage(named: "Circular") else { handler(nil); return}
                template.imageProvider = CLKImageProvider(onePieceImage: image)
                handler(template)

            } else if complication.family == .utilitarianSmall {

                let template = CLKComplicationTemplateUtilitarianSmallRingImage()
                guard let image = UIImage(named: "Utilitarian") else { handler(nil); return}
                template.imageProvider = CLKImageProvider(onePieceImage: image)
                handler(template)

            } else if complication.family == .modularSmall {

                let template = CLKComplicationTemplateModularSmallRingImage()
                guard let image = UIImage(named: "Modular") else { handler(nil); return}
                template.imageProvider = CLKImageProvider(onePieceImage: image)
                handler(template)

            } else {

                handler(nil)

            }
        }


    }







}

1 Ответ

0 голосов
/ 26 октября 2018

Вы и я столкнулись с этой проблемой одновременно. С этой страницы:

https://forums.developer.apple.com/thread/108598

Добавьте ClockKit.framework как опционально в фазе Link Binary With Libraries вашего расширения часов. Это позаботилось о моей проблеме сразу.

...