简体   繁体   English

我可以拥有一个适用于 OS X 和 tvOS 的跨平台框架吗?

[英]Can I have a cross-platform framework for OS X and tvOS?

I am writing a tvOS app.我正在编写一个 tvOS 应用程序。 Up to now I was developing the code as an OS X framework with a prototyping OS X app.到目前为止,我正在将代码开发为带有原型 OS X 应用程序的 OS X 框架。

Now I would like to add the production tvOS app into the mix, keeping the OS X prototype .现在我想将生产 tvOS 应用程序添加到组合中,保留 OS X 原型 Which means I need the framework to be built both for OS X and tvOS.这意味着我需要为 OS X 和 tvOS 构建框架。 This should not be a problem in the principle, since I only use frameworks available on both platforms.这在原则上应该不是问题,因为我只使用两个平台上都可用的框架。

Is it possible to build a cross-platform framework?是否可以构建跨平台框架? What settings do I use?我使用什么设置?

Yes it's commonly done.是的,通常这样做。 Create a new Xcode target, targetting tvOS, and add the same source files as the OSX target.创建一个新的 Xcode 目标,以 tvOS 为目标,并添加与 OSX 目标相同的源文件。

If you need to include/exclude/change code or behaviour at compile time then you need to #import <TargetConditionals.h> .如果您需要在编译时包含/排除/更改代码或行为,那么您需要#import <TargetConditionals.h>

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

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