Thomas
03/26/2019, 11:42 AMfailed to demangle superclass of MainViewController from mangled name '13MyProject22BaseViewControllerCySo16MyItemCSo0G24MyPresenter_pG'
This is the original line in Swift:
class MainViewController: BaseViewController<MyItem, MyPresenter>, MyView
(MyItem, MyPresenter, MyView are Kotlin classes)
I found this in the release notes under "Known Issues" (https://developer.apple.com/documentation/xcode_release_notes/xcode_10_2_release_notes/swift_5_release_notes_for_xcode_10_2):
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 ‘<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.
I tried adding the all_load linker flag to my Xcode project but there was no difference, but I might have added it wrong as I am very new to Xcode. Could anyone help me out?svyatoslav.scherbina
03/26/2019, 12:04 PMBaseViewController
declared? Is it the same Swift module?
Would the crash happen if no Kotlin classes were involved?svyatoslav.scherbina
03/26/2019, 12:08 PMThomas
03/26/2019, 12:16 PMBaseViewController
is located in the same Swift module. I've tried a clean build as well but still got the crash.Thomas
03/26/2019, 12:18 PMThomas
03/26/2019, 12:20 PMclass MainViewController: UIViewController, MyView
(MyView is a Kotlin interface)svyatoslav.scherbina
03/26/2019, 12:32 PMsvyatoslav.scherbina
03/26/2019, 12:59 PMsvyatoslav.scherbina
03/26/2019, 1:34 PMlet kotlinProtocols = [Foo.self, Bar.self]
to any Swift file, where Foo
and Bar
are Kotlin interfaces used as generic parameters.Thomas
03/26/2019, 2:00 PMsvyatoslav.scherbina
03/26/2019, 2:03 PMThomas
03/26/2019, 6:41 PMsvyatoslav.scherbina
03/26/2019, 7:15 PMsvyatoslav.scherbina
06/20/2019, 9:16 AMThomas
06/20/2019, 9:45 AMsvyatoslav.scherbina
06/20/2019, 9:50 AMThomas
06/20/2019, 9:52 AMlouiscad
06/20/2019, 11:37 AMsvyatoslav.scherbina
06/20/2019, 11:58 AMThomas
06/20/2019, 12:04 PMcommon.framework
is the Kotlin framework.svyatoslav.scherbina
06/20/2019, 12:44 PMsvyatoslav.scherbina
06/20/2019, 12:46 PMIs there an issue we can follow?https://bugs.swift.org/browse/SR-10177 https://bugs.swift.org/browse/SR-10217
Thomas
06/20/2019, 12:49 PMPlease ensure that you have the framework enumerated under “Link Binary With Libraries” build phase of your application.@svyatoslav.scherbina These are the build phases in my project
svyatoslav.scherbina
06/20/2019, 12:52 PMprint(Foo())
, where Foo
in declared in Kotlin.Thomas
06/20/2019, 1:11 PMsvyatoslav.scherbina
06/20/2019, 1:17 PMThomas
06/20/2019, 1:18 PMThomas
06/20/2019, 1:19 PMsvyatoslav.scherbina
06/20/2019, 1:23 PMclass Foo
to your Kotlin code. It must be a class
, not an interface
.
2. Add top-level property let foo = Foo.self
to your Swift code.Thomas
06/20/2019, 1:39 PMclass Foo
to my Kotlin code. Then I added let foo = Foo.self
at the top of a file in my Swift code. The app works fine in the simulator and does not crash on start.svyatoslav.scherbina
06/20/2019, 1:50 PMThomas
06/20/2019, 2:08 PM