我已经在Swift中实现了手表套件的复杂性。我想将调试器附加到Complication Controller。我意识到,复杂控制器仅被调用一次,然后被缓存。但是,我无法使调试器附加到手表套件扩展上。该应用程序加载到我的真实Watch中,然后进入XCode> Debug> Attach to Process(扩展名)。调试器似乎附加到了扩展名,但是未击中complication.family 的 getLocalizableSampleTemplate处的断点。我尝试从iPhone上的手表配套应用程序中卸载该应用程序,然后让XCode自动将其安装在手表上,然后强行按下表盘,但仍然没有碰到断点。如果有人有一个使它可靠运行的过程,我将不胜感激。 Xcode 10.1。观看OS 5.1.3。 iOS 12.1.2。
import WatchKit
import ClockKit
class ComplicationController: NSObject, CLKComplicationDataSource {
var watchSize: String = ""
var imageName : String = ""
// MARK: Register
func getLocalizableSampleTemplate(for complication:
CLKComplication, withHandler handler:
@escaping (CLKComplicationTemplate?) -> Swift.Void) {
// 1
if complication.family == .modularSmall {
// 2
let modularSmall = CLKComplicationTemplateModularSmallSimpleImage()
let imageName = "bell-icon"
let image = UIImage(named: imageName)
modularSmall.imageProvider = CLKImageProvider(onePieceImage:image!)
modularSmall.imageProvider.tintColor = UIColor.blue
handler(modularSmall)
}else if complication.family == .utilitarianSmall{
let utilitarianSmall = CLKComplicationTemplateUtilitarianSmallSquare()
let imageName = "bell-icon"
let image = UIImage(named: imageName)
utilitarianSmall.imageProvider = CLKImageProvider(onePieceImage:image!)
utilitarianSmall.imageProvider.tintColor = UIColor.blue
handler(utilitarianSmall)
} else if complication.family == .circularSmall{
let circularSmall = CLKComplicationTemplateCircularSmallRingImage()
let imageName = "bell-icon"
let image = UIImage(named: imageName)
circularSmall.imageProvider = CLKImageProvider(onePieceImage: image!)
circularSmall.imageProvider.tintColor = UIColor.blue
handler(circularSmall)
}
}