I’ve been using Swift since it was announced in 2014. When adding @objcMembers to a class of a Mac app I’m developing I received the autocompletion recommendation @objc_non_lazy_realization. This is not mentioned a single time in Apple’s Swift Programming Language book or “Using Swift with Cocoa and Objective-C”. I admit that I don’t know very much beyond what’s necessary about Swift at the compiler level, but I’m curious about what this does. The only use of this line I could find online is in the Swift source code. Although it’s not vital to using Swift, I’m super interested and would like to know!

Jared Stefanowicz

This appears to be an internal attribute to disable lazy resolution of class names by the Objective-C runtime. A quick search shows that it's used inside the Swift standard library for _EmptyArrayStorage. From the comments above it, it seems like this class needs to be available statically for whatever reason, so the attribute is added to make sure this is the case. Either way, you shouldn't be using it in your code!

Please file a bug about this. Code completion certainly shouldn't be suggesting this, and it probably makes sense for the attribute to be underbared (@objc...) since it doesn't follow the naming conventions and isn't really meant for public use.