简体   繁体   English

如何向我现有的 Xcode 项目添加复杂功能?

[英]How can I add complications to my EXISTING Xcode project?

How can I add complications to my EXISTING Xcode 7 project ?如何向我现有的Xcode 7 项目添加复杂功能?

Looking at WWDC video 2015 session 209 the way shown to add complications is to create a new project and click on Include Complication .查看 WWDC 视频 2015 session 209,显示的添加复杂功能的方法是创建一个新项目并单击Include Complication This works fine for that case but how can I add them in an existing project?这适用于这种情况,但如何将它们添加到现有项目中?

在此处输入图片说明

I can't find a complication controller in the XCode object selector (See below):我在 XCode 对象选择器中找不到复杂化控制器(见下文):

在此处输入图片说明

Why is this happening??为什么会这样??

Add a new temp watch extension target and check the complication check box.添加新的临时监视扩展目标并选中复杂功能复选框。 Copy the complication extension properties from this new info.plist (CLKComplicationSupportedFamilies, WKExtensionDelegateClassName & CLKComplicationPrincipalClass) into your old watch extension info.plist.将这个新的 info.plist(CLKComplicationSupportedFamilies、WKExtensionDelegateClassName 和 CLKComplicationPrincipalClass)中的复杂功能扩展属性复制到您的旧手表扩展 info.plist 中。 Once you do that you will see the complication Families listing.完成此操作后,您将看到复杂功能系列列表。

I also moved the ExtensionDelegate & ComplicationController classes into the old watch extension and changed the target membership to the old watch extension from the new watch extension.我还将 ExtensionDelegate 和 ComplicationController 类移动到旧手表扩展中,并将目标成员资格从新手表扩展更改为旧手表扩展。

Right click inside the old watch extension asset file and add the complication image set.右键单击旧手表扩展资产文件并添加复杂功能图像集。

Also "tom_witkin Jul 23, 2015 8:50 AM (in response to breville) The ClockKit framework is only available on watchOS 2, not iOS. Thus, complications are not supported for existing WatchKit apps where the extension is running on the iPhone."此外,“tom_witkin 2015 年 7 月 23 日上午 8:50(回应 breville)ClockKit 框架仅适用于 watchOS 2,而不适用于 iOS。因此,在 iPhone 上运行扩展程序的现有 WatchKit 应用程序不支持复杂性。”

So do the recommended build settings change when moving from wos1 to wos2 (if there is a warning during compilation), and make WATCHOS_DEPLOYMENT_TARGET = 2.0 in both the old extension & watch app build settings.因此,当从 wos1 移动到 wos2 时(如果在编译过程中出现警告),建议的构建设置是否更改,并在旧扩展和手表应用程序构建设置中设置 WATCHOS_DEPLOYMENT_TARGET = 2.0。

Add TARGETED_DEVICE_FAMILY = 4 for old watch extension, if not present.如果不存在,为旧手表扩展添加 TARGETED_DEVICE_FAMILY = 4。

There is no such thing like a complication controller in Interface Builder it is an abstract entity. Interface Builder 中没有像复杂控制器这样的东西,它是一个抽象实体。 You should use ClockKit Framework to register timeline entries and only after that these entries will be available through supported complications on Watch faces.您应该使用ClockKit 框架来注册时间线条目,只有在此之后,这些条目才能通过表盘上支持的复杂功能使用。

You can configure supported complication types on your Watch Extension target configuration tab - just check necessary checkboxes.您可以在 Watch Extension 目标配置选项卡上配置支持的复杂类型 - 只需选中必要的复选框。 And there is a trick you should specify a name of your complication controller using the next scheme: $(PRODUCT_MODULE_NAME).YourComplicationControllerName还有一个技巧,您应该使用下一个方案指定复杂控制器的名称: $(PRODUCT_MODULE_NAME).YourComplicationControllerName

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM