p-x9 / AssociatedObject

🔗 Swift Macro for allowing variable declarations even in class extensions
MIT License
130 stars 4 forks source link

Building error: duplicate symbol '__associated_object_key' #34

Closed Mx-Iris closed 8 months ago

Mx-Iris commented 8 months ago

I used the library in both libraries and the compilation reported an error, maybe due to @_exported import AssociatedObjectC? , because the duplicate symbols come from here

duplicate symbol '__associated_object_key' in:
ld: 1 duplicate symbols
clang: error: linker command failed with exit code 1 (use -v to see invocation)

1 duplicate symbols

Linker command failed with exit code 1 (use -v to see invocation)
p-x9 commented 8 months ago

Hello. Are you using this with CocoaPods?

Mx-Iris commented 8 months ago

Hello. Are you using this with CocoaPods?

I using SwiftPM

This does not seem to be a problem caused by references from multiple libraries. I encountered this issue when I added an associated object in an extension of NSView and then added another associated object in an extension of NSControl. NSControl inherits from NSView.

p-x9 commented 8 months ago

Thanks. I have tried it and it seems to work fine for me.

Maybe a clean build will get it to work.

Mx-Iris commented 8 months ago

MyLibrary.zip This is an example that can be reappear by importing the library in two different files

p-x9 commented 8 months ago

Thanks. It certainly did not work. Sorry.

It was probably because I had implemented the _associated_object_key function in the header file.