What's the right way to distinguish between corelibs frameworks from Apple propreitary ones?

Concrete example: I'm writing some code that relies on some internal APIs of Apple's proprietary XCTest implementation, which aren't available in the open source "corelibs" implementation.

What's the correct way to discriminate between the two cases?

Currently I'm using:

#if _runtime(_ObjC)
    print("We're probably using the proprietary implementation of XCTest")
#elseif _runtime(_Native)
    print("We're probably using the open source implementation of XCTest")
#else
    #error("Unrecognized runtime")
#endif

But this seems indirect, and perhaps error-prone. E.g. can a person " crisscross" things and use the open source XCTest on a Mac?

1 Like