Duplicate symbol linker errors when using C++ types

I'm working on building a SwiftUI application on top of an existing C++ model layer. I'm having an issue where when multiple Swift files refer to the same model objects, I start getting duplicate symbol warnings in the linker.


duplicate symbol '_$sSo3DfpO12MyCPPClassNameVMa' in:

I'm not entirely sure why this is happening - I'm trying to narrow it down to a specific set of conditions I could reproduce. I am doing things like extending my C++ types to conform to Identifiable. But I can't reliably trace these issues directly to the existence of extending C++ types.

Are there any known issues in Xcode 15.0.1 with C++ types creating duplicate symbols?


Hi there,

I'm having the same issue but in SwiftUI

I narrowed it down to having the duplicate symbols linker error when using SwiftUI property wrappers, ie: @State var whatever: MyCxxType. By not using @State, for example, the issue disappears.

1 Like

I'm experiencing this same issue. I'm not using any property wrappers around my C++ types and I'm seeing duplicate symbols in nearly every file that imports my C++ library.