Missing diagnostic for super convenience init call?

Repository and commit for context: swift-cross-ui at d763c22

When compiling DatePickerExample (in the Examples folder) using GtkBackend, I got this linker error:

error: undefined reference to '$s3Gtk3BoxC11orientation7spacingAcA11OrientationO_Sitcfc'

Helpful as all linker errors are, I had to investigate myself. The "missing" symbol is Gtk.Box.init(orientation:spacing:), which is defined here and called here. The call site is a super.init call, which I had forgotten at the time isn't allowed to call a convenience init. If I manually inline the convenience initializer, changing the call site to:

super.init(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0))

then it compiles and runs fine.

Why was this misuse of a convenience initializer undiagnosed? Or if it's expected to work (which I don't think it is), why did it give a linker error? Is this a known issue?

I believe so. Was the module declaring the convenience init built as a textual interface?

I don't believe so. You can look at the Package.swift as of that commit yourself, but it just has

        .target(
            name: "GtkBackend",
            dependencies: ["SwiftCrossUI", "Gtk", "CGtk"]
        ),

and

        .target(
            name: "Gtk",
            dependencies: ["CGtk", "GtkCustomWidgets"],
            exclude: ["LICENSE.md"],
            swiftSettings: gtkSwiftSettings
        ),

Where gtkSwiftSettings is an empty array for Gtk 4.0..<4.10 and [.define("GTK_4_10_PLUS")] for Gtk 4.10 and later.

(Gtk is the module defining the convenience init, and GtkBackend is the module attempting to call it.)

1 Like