在使用针对所有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 FlagsAnd 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)
更多推荐
发布评论