问题描述
我们的应用程序支持iOS 11及更高版本.在iOS 13中,我们使用 SwiftUI
+ Combine
Our application supports iOS 11 and higher. In iOS 13 we use SwiftUI
+ Combine
我们用相应的检查 #if canImport(SwiftUI)
或 #if canImport(Combine)包装
.如果我们在iOS 12下从Xcode 11运行应用程序,则会出现错误 SwiftUI
或 Combine
框架的导入) dyld:库未加载:/System/Library/Frameworks/Combine.framework/Combine
we wrap import of SwiftUI
or Combine
framework with correspondent check #if canImport(SwiftUI)
or #if canImport(Combine)
. If we run our app from Xcode 11 under iOS 12 we have error dyld: Library not loaded: /System/Library/Frameworks/Combine.framework/Combine
我们通过可选地链接来解决SwiftUI的相同问题.
We fixed same issue for SwiftUI by linking it optionally.
但是我们不能为Combine设置相同的名称,因为甚至无法选择它进行链接
But we can't make same for Combine as it can not be even selected for linking
推荐答案
您可以显式添加链接器标志,以便在构建设置中可用时(可选)链接组合".在"Xcode构建设置"中,将 -weak_framework组合添加到其他链接器标记.
You can add the linker flags explicitly to optionally link Combine when it is available in the build settings.In the Xcode Build Settings add -weak_framework Combine to Other Linker Flags.
或在您的XCConfig文件中添加以下行:
Or add the following line in your XCConfig file:
OTHER_LDFLAGS = -weak_framework Combine
或者如果您仍然想支持使用旧版Xcode进行构建:
or if you still want to support building with older Xcode versions:
OTHER_LDFLAGS[sdk=iphoneos13.0] = -weak_framework Combine
OTHER_LDFLAGS[sdk=iphonesimulator13.0] = -weak_framework Combine
OTHER_LDFLAGS[sdk=watchos6.0] = -weak_framework Combine
OTHER_LDFLAGS[sdk=watchsimulator6.0] = -weak_framework Combine
OTHER_LDFLAGS[sdk=appletvos13.0] = -weak_framework Combine
OTHER_LDFLAGS[sdk=appletvsimulator13.0] = -weak_framework Combine
OTHER_LDFLAGS[sdk=macosx10.15] = -weak_framework Combine
这篇关于Xcode 11中Swift Combine.framework的可选链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!