Vincent Bacalso
Vincent Bacalso

Reputation: 2147

Detect if iOS App is written in Swift

Im developing a tool that tries to dump header classes for a jailbroken device on an App. I'm using Clutch, but sometimes Clutch fails to some newer apps, I'm thinking of integrating some tools other than Clutch. So, I need to determine at first if the binary is written in Swift, so that I can switch to the right tool to execute.

My question is, Is there a way, like a command tool to determine if an iOS App Binary is written in Swift? Is there really much difference in how the binary is built when it's in Swift compare to just Obj-C?

Upvotes: 5

Views: 3567

Answers (2)

Adam
Adam

Reputation: 26907

You can use nm tool to print app symbol table. If you search for swift, for example using grep:

nm YourApp | grep swift

It will print something like this (and many more):

U __swift_FORCE_LOAD_$_swiftFoundation

For an 100% Objective-C app the result will be empty. However, you can't tell if the code is 100% Swift because for mixed objc + swift apps the result will be similar to a swift app.

Upvotes: 9

Swinny89
Swinny89

Reputation: 7373

Inside the .app file there is a _CodeSignature folder. Inside there is a CodeResources file. If you open that as text you will see that it contains Frameworks/libswiftCore.dylib

I believe this indicates that it has been built with swift.

Upvotes: 7

Related Questions