无法使用Xcode 10.2中的Cocoapods分解超类 [英] Failed to demangle superclass with Cocoapods in Xcode 10.2

查看:53
本文介绍了无法使用Xcode 10.2中的Cocoapods分解超类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

移动到Xcode 10.2之后,运行我的应用程序时出现崩溃,错误为无法将MyClass的超类从变形的名称MySuperClass 分解。



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



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

  //内部Pod B:
开放类MySuperClass< DataType:Decodable> {...}

//内部Pod A:
开放类MySubClass:MySuperClass< AConcreteStructConformingToCodable> {...}

//在我的项目中:
让myClass = MySubClass()

我尝试覆盖Pod构建设置,无论是否进行了优化,都无需进行任何行为更改。

解决方案

我已经在



希望这对其他人有帮助!


After moving to Xcode 10.2, when running my app I get a crash with the error failed to demangle superclass of MyClass from mangled name MySuperClass.

The crash occurs when I try to create an instance of MyClass. I am using CocoaPods 1.6.1 and have not yet upgraded to Swift 5. The class in question is defined inside a Pod, and is a subclass of a class defined a different Pod (listed as a sub dependency of the first Pod).

Adding to the complexity (unsure if it is related) is that the super class takes a generic, and the sub class defines a concrete type and does not take a generic. I.e.

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

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

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

I have tried overriding the Pod build settings to build with and without optmisation without any change in behaviour.

解决方案

I have discovered this in the Xcode 10.2 Release Notes, under "Swift Compiler" -> "Known Issues":

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.

And I was able to resolve the issue by adding -all_load to Other Linker Flags of the main Project:

Hope this helps someone else!

这篇关于无法使用Xcode 10.2中的Cocoapods分解超类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆