gpt4 book ai didi

ios - 无法在 Xcode 10.2 中使用 Cocoapods 分解父类(super class)

转载 作者:IT王子 更新时间:2023-10-29 05:51:13 25 4
gpt4 key购买 nike

迁移到 Xcode 10.2 后,在运行我的应用程序时出现崩溃,错误为 failed to demangle superclass of MyClass from mangled name MySuperClass

当我尝试创建 MyClass 的实例时发生崩溃。我正在使用 CocoaPods 1.6.1 并且尚未升级到 Swift 5。有问题的类在 Pod 内定义,并且是定义不同 Pod 的类的子类(列为第一个 Pod 的子依赖项)。

增加复杂性(不确定是否相关)的是父类(super class)采用泛型,子类定义具体类型而不采用泛型。即

// Inside Pod B:
open class MySuperClass<DataType: Decodable> { ... }

// Inside Pod A:
open class MySubClass: MySuperClass<AConcreteStructConformingToCodable> { ... }

// Inside my project:
let myClass = MySubClass()

我已经尝试覆盖 Pod build设置以在没有任何行为变化的情况下进行优化和不优化构建。

最佳答案

我在 Xcode 10.2 Release Notes 中发现了这个,在“Swift 编译器”->“已知问题”下:

Linking against a static Swift library might create a binary with missing type metadata because the object files that define the metadata inside the static archive are mistakenly considered unused. (47598583)

This can manifest as a Swift runtime error with a message such as: “failed to demangle superclass of MyClass from mangled name ‘’”.

Workaround: If you can rebuild the static library, try building it with whole module optimization enabled. Otherwise, add -all_load to the linker flags in the client binary to ensure all object files are linked into it.

我能够通过将 -all_load 添加到主要项目的其他链接器标志来解决这个问题:

-all_load linker flag

希望这对其他人有帮助!

关于ios - 无法在 Xcode 10.2 中使用 Cocoapods 分解父类(super class),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55584094/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com