ClockKit和WidgetKit在同一个应用中的复杂性

huangapple go评论59阅读模式
英文:

ClockKit and WidgetKit Complications in the same app

问题

我正在开发一个支持从watchOS 7.0到最新版本的应用程序,在应用本身方面进展顺利,但在复杂情况下遇到了一些问题。我有两组正常工作的复杂情况,一组使用WidgetKit制作,另一组使用ClockKit制作,但由于它们的工作方式完全不同,我在将它们连接起来方面遇到了一些问题。我希望我的ClockKit复杂情况在watchOS版本低于9时显示,而WidgetKit复杂情况在watchOS版本为9或更高时显示。

目前我有三个相关的目标,一个是表盘目标,一个是表盘扩展目标,另一个是复杂情况的不同目标,因为据我所知,你只能使用@main设置WidgetKit复杂情况的入口点,并且每个目标只能有一个@main,所以我不能将它放在表盘扩展目标中,我的应用的其余部分也在其中,甚至ClockKit复杂情况也是如此,因为它们可以在目标>复杂情况配置选项中设置。

在我的WidgetKit复杂情况目标的Info.plist文件中,我有以下内容:

在这里输入图像描述

在NSExtensionPointIdentifier字段中,我在两个值之间切换:

com.apple.widgetkit-extension:每当我使用此值时,应用程序和复杂情况将在watchOS 9+上正常工作,显示我的WidgetKit复杂情况,但在watchOS 9-上不会启动,显示“无法安装此时... ios.aplicacion.tiempo-com.watchkitapp.watchkitextension.CompliWatchExt在其Info.plist中的NSExtension字典的NSExtensionPointIdentifier键上指定了一个值(com.apple.widgetkit-extension),该值与已知的扩展点不对应。” 因此,它无法识别widgetkit-extension标识符。

com.apple.services:虽然我觉得这只是任何非“widgetkit-extension”的东西,因为这基本上消除了WidgetKit复杂情况,使其在任何版本上工作,但只有ClockKit复杂情况。

所以基本上我想要的是,在watchOS 9+上,应用程序像有com.apple.widgetkit-extension一样工作,但在watchOS 9-上,应用程序像有com.apple.services一样工作,有没有办法获得这个结果?

英文:

I am working on an application for watchOS that needs support from watchOS 7.0 to the last version, in terms of the app itself its going well, but I'm having problems with the complications, I have two sets of working complications, one made with WidgetKit and one with ClockKit, but as they work entirely differently I'm having some trouble connecting the two of them, I want my ClockKit complications to show when the watchOS versions in below 9 and the WidgetKit Complications to show when the watchOS version in 9 or above.

Right now I have three targets that are relevant, a watch target, a watch extension target and a different target for the Complications, because as far as I know you can only set the entry point for the WidgetKit Complications using @main and you can only have one @main per target, so I couldn't have it in the watch extension target in which the rest of my app is, even the ClockKit Complications, as they can be set in the target>Complications Configuration options

In the Info.plist file of my WidgetKit complications target I have the following:

enter image description here

On the NSExtensionPointIdentifier field I change between two values:

> com.apple.widgetkit-extension : Whenever I have this value, the app and complications will work fine on watchOS 9+, showing my WidgetKit Complications, however it wouldn't launch on watchOS 9-, saying that "Could not install at this time ... ios.aplicacion.tiempo-com.watchkitapp.watchkitextension.CompliWatchExt specifies a value (com.apple.widgetkit-extension) for the NSExtensionPointIdentifier key in the NSExtension dictionary in its Info.plist that does not correspond to a known extension point." So it doesn't recognize the widgetkit-extension identifier.

> com.apple.services : Although I feel this is just any non "widgetkit-extension", because this basically gets rid of the WidgetKit Complications, making it work on any version but only having the ClockKit Complications.

So basically what I want is the app to work as if it had com.apple.widgetkit-extension on watchOS 9+ but to work as it had com.apple.services on watchOS 9-, is there any way to get this result?

答案1

得分: 1

我找到了解决方案,尽管这并不真正是一个解决方案,只是我的一种误解,我所需要做的唯一一件事就是在我拥有 Widget Complications 的目标中将部署目标设置为 9.0,因为当两者都可用时,Xcode 会优先使用小部件工具包的复杂情况。

英文:

Okey I found the solution although it's not really a solution, It was just a misconception from my part, the only thing I needed to do was set the Deployment target to 9.0 in the target I had the Widget Complications in, as Xcode gives preference to the widget kit complications when both are available

huangapple
  • 本文由 发表于 2023年6月15日 17:11:32
  • 转载请务必保留本文链接:https://go.coder-hub.com/76480933.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定