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.

I.E.:

duplicate symbol '_$sSo3DfpO12MyCPPClassNameVMa' in:
/Users/colincornaby/Library/Developer/Xcode/DerivedData/MyApp-adhylznzathfczdykvikhffclgfa/Build/Intermediates.noindex/MyApp.build/Debug/MyApp.build/Objects-normal/x86_64/ASwiftFile.o
/Users/colincornaby/Library/Developer/Xcode/DerivedData/MyApp-adhylznzathfczdykvikhffclgfa/Build/Intermediates.noindex/MyApp.build/Debug/MyApp.build/Objects-normal/x86_64/AnotherSwiftFile.o

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?

1 Like