Reputation: 1656
I'm developing framework(objc) and I need to detect that application uses swift. It doesn't matter that app developed on swift completely or it's swift/objc hybrid.
Do you have and ideas how to get this information? I've thought about objc runtime but I don't know how I can implement that.
Great thanks.
I don't know why my previous question has been closed. But I'll try to be more focused: I need to get information how many clients which integrate my framework use swift as a programming language so I must to detect that a project uses swift.
Upvotes: 4
Views: 390
Reputation: 258375
Please find below the possible approach based on public documented dyld
API available since iPhone2 and valid for all modern iOS versions. And libswiftCore.dylib
is present always for swift.
Taking into account that Swift might be in some application plug-ins, the below function should be called regularly (or at least till first positive result) on your framework API call.
#import <mach-o/dyld.h>
BOOL isSwiftLoaded() {
return NSVersionOfRunTimeLibrary("libswiftCore.dylib") != -1;
// -1 is documented indicator that library is not loaded
}
Upvotes: 4