Can I have a cross-platform framework for OS X and

2019-07-13 08:44发布

问题:

I am writing a tvOS app. Up to now I was developing the code as an OS X framework with a prototyping OS X app.

Now I would like to add the production tvOS app into the mix, keeping the OS X prototype. Which means I need the framework to be built both for OS X and 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?

回答1:

Yes it's commonly done. Create a new Xcode target, targetting tvOS, and add the same source files as the OSX target.

If you need to include/exclude/change code or behaviour at compile time then you need to #import <TargetConditionals.h>.