p-x9 / AssociatedObject

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

Viability on non-Apple platforms #17

Closed mickeyl closed 7 months ago

mickeyl commented 11 months ago

Naturally this only works on platforms where Swift is backed by an Objective-C runtime. I wonder how we could extend this to other platforms where this isn‘t available, perhaps using a global in memory storage area?

p-x9 commented 11 months ago

Indeed, due to the dependency on ObjectiveC, the build was failing on Linux.

https://swiftpackageindex.com/p-x9/AssociatedObject/builds

The basic implementation by Apple of associatedObject is found in the following.

https://github.com/apple-oss-distributions/objc4/blob/689525d556eb3dee1ffb700423bccf5ecc501dbf/runtime/objc-references.mm

A similar implementation might allow for similar functionality outside of the Apple platform.

p-x9 commented 7 months ago

Hello, @mickeyl It's been some time, but I just created a library of Associated object that can work on Linux and other platforms.

https://github.com/p-x9/swift-object-association

I would like to consider including its introduction to this AssociatedObject Macro in the future.

p-x9 commented 7 months ago

Supported in version 0.10.0