gpt4 book ai didi

swift - 结合 Watch OS 和 iOS 框架

转载 作者:可可西里 更新时间:2023-11-01 00:56:48 24 4
gpt4 key购买 nike

我创建了一个在 iOS 和 Watch OS 之间共享的类。这很好用。但是,我想将该类变成一个框架。这样做虽然只允许将其创建为 iOS 或 Watch OS 框架,但不能同时创建两者。为 Watch OS 创建它会阻止 iOS 看到它,反之亦然。

我怎样才能拥有 iOS 和 Watch OS 都可以使用的单一框架?

最佳答案

我在询问后立即找到了隐藏在文档中的答案...为了其他人的利益,我不会删除问题,而是将答案发布在这里:

根据 Apple 的说法,您不能在 watch 和手机之间共享框架。具体来说:

Sharing Code Between an iOS App and a watchOS App

You can share code, but not frameworks, between your iOS app and Watch app. Because the apps run on separate platforms with different architectures, source files must be compiled separately for each platform. If you still want to use a framework to manage any shared source files, you must create separate framework targets for each platform and add your shared source files to each framework.

If you already have an iOS framework, you can duplicate the framework and modify it to support watchOS.

https://developer.apple.com/library/content/documentation/General/Conceptual/WatchKitProgrammingGuide/iOSSupport.html#//apple_ref/doc/uid/TP40014969-CH21-SW1

关于swift - 结合 Watch OS 和 iOS 框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45498554/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com