Xcode:通用框架:有条件地仅为特定平台链接其他.framework依赖项(Xcode: Universal framework: Conditionally link other .framewo

编程入门 行业动态 更新时间:2024-10-28 20:19:00
Xcode:通用框架:有条件地仅为特定平台链接其他.framework依赖项(Xcode: Universal framework: Conditionally link other .framework dependency for specific platform only)

在使用针对所有Apple平台的通用框架时,我希望有条件地链接到OSX的另一个.framework依赖项。

我可以将此依赖项添加到Linked Framework和Libraries,并将其标记为Optional。 但是,我不知道应该在Build Settings添加或修改哪个自定义字段,以便仅为特定平台实际链接此.framework 。 (没有任何东西,因为依赖是可选的 - 构建将始终失败,并且ld: framework not found )

有什么建议吗?

作为一种解决方法,我可以将其分为两个目标:一个用于OSX,一个用于其他任何目标,但这已经破坏了通用框架的概念。

While working with universal framework that targets all apple platforms I wish to conditionally link to another .framework dependency for OSX only.

I can add this dependency to Linked Framework and Libraries and mark it as Optional. However I don't know what custom field should I add or modify in Build Settings to only actually link this .framework for specific platform only. (without anything since the dependency is optional - build will always fail with ld: framework not found)

Any suggestion guys?

As a workaround I can split this over two targets: one for OSX and one for anything else, but that will already derail the concept of universal framework.

最满意答案

这可以在不借助Linked Framework和Libraries的情况下实现。

虽然我们有一个支持全系列平台的通用目标: macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator ,考虑我们只想连接OSX框架的情况。

为了链接我们的框架,我们需要两件事:

将所需的.framework路径添加到Framework Search Path 将-framework YourFrameworkName添加到其他链接器标志

而Build设置允许我们为特定平台指定条件字段。 展开单个字段并将鼠标悬停在Debug / Release上时,您将看到加号出现,按加号将为您提供选择器,您可以在其中选择所需的平台。

用于链接Realm和RealmSwift for OSX的假设添加构建设置将采用以下方式:

(英特尔64位arch和任何macOS SDK都代表OSX的构建)

This can be achieved without resorting to Linked Framework and Libraries.

While we have a universal target with full range of supported platforms: macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator, consider the case that we want to link a framework for OSX only.

For linking our framework we need two things:

Add the path to desired .framework to Framework Search Path Add -framework YourFrameworkName to Other Linker Flags

And Build settings allows us to specify fields conditional for specific platform. When expanding the individual field and hovering the mouse over Debug/Release, you will be able see the plus sign appearing, pressing on the plus sign will bring you the picker where you will be able to select the desired platform.

The hypothetical added build settings for linking Realm and RealmSwift for OSX will look the following way:

(both Intel 64-bit arch and Any macOS SDK will represent building for OSX)

更多推荐

本文发布于:2023-08-05 04:21:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1427665.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:仅为   有条件   框架   链接   平台

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!