ios - 迪尔德 : Library not loaded SwiftUI when app runs on iOS 12 using @available(iOS 13. 0, *)

标签 ios swift xcode swiftui

我决定在我的应用程序中使用 SwiftUI 实现一些 View 。该应用程序向后兼容 iOS 12。

一切都很完美,直到我在 iOS 12 设备上运行它。应用程序立即崩溃,我收到的警告说无法加载 SwiftUI。

dyld: Library not loaded: /System/Library/Frameworks/SwiftUI.framework/SwiftUI
  Referenced from: /var/containers/Bundle/Application/MyApp.app/MyApp
  Reason: image not found

我在所有正确的位置使用 @available(iOS 13.0, *),并且没有编译器警告,并且应用程序在 iOS 13 上完美运行

如何让它适用于 iOS 12?

最佳答案

事实证明这是一个已知问题,苹果引入了一个新的build设置标志来处理它

Apps containing SwiftUI inside a Swift package might not run on versions of iOS earlier than iOS 13. (53706729)

Workaround:

When back-deploying to an OS which doesn't contain the SwiftUI framework, add the -weak_framework SwiftUI flag to the Other Linker Flags setting in the Build Settings tab. See Frameworks and Weak Linking for more information on weak linking a framework. This workaround doesn't apply when using dynamically linked Swift packages which import SwiftUI.

-weak_framework SwiftUI 添加到其他链接器标志解决了我的问题

关于ios - 迪尔德 : Library not loaded SwiftUI when app runs on iOS 12 using @available(iOS 13. 0, *),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57907817/

相关文章:

iOS - UIWebview 在滚动时部分消失

swift - 构建失败 : unable to open file (in target '' in project '' )(in target '' )

ios - iPhone 应用签名 : A valid signing identity matching this profile could not be found in your keychain

iphone - scrollViewDidScroll 委托(delegate)正在自动调用

ios - 导航标题不显示

c++ - 安装 cocoa pod 后,现有静态库不使用 libssl.a 进行 tls 连接并且访问权限不佳

ios - Realm 、对象已被删除或失效

arrays - 通过removeAtIndex(Index : Int) function)从数组中删除特定元素时出现问题

ios - 重新加载表会导致闪烁

ios - UITableViewCell 显示点击删除按钮