[英]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. 我开发了一个工具,试图在App上转储越狱设备的头类。 I'm using Clutch , but sometimes Clutch fails to some newer apps, I'm thinking of integrating some tools other than Clutch.
我正在使用Clutch ,但有时Clutch无法使用一些较新的应用程序,我正在考虑集成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.
因此,我首先需要确定二进制文件是否是用Swift编写的,这样我就可以切换到正确的工具来执行。
My question is, Is there a way, like a command tool to determine if an iOS App Binary is written in Swift? 我的问题是, 有没有办法,比如命令工具来确定iOS App二进制文件是否是用Swift编写的? Is there really much difference in how the binary is built when it's in Swift compare to just Obj-C?
与只有Obj-C相比,在Swift中构建二进制文件的方式真的有很大不同吗?
Inside the .app file there is a _CodeSignature folder. 在.app文件中有一个_CodeSignature文件夹。 Inside there is a CodeResources file.
里面有一个CodeResources文件。 If you open that as text you will see that it contains
Frameworks/libswiftCore.dylib
如果你打开它作为文本,你会看到它包含
Frameworks/libswiftCore.dylib
I believe this indicates that it has been built with swift. 我相信这表明它是用swift构建的。
You can use nm tool to print app symbol table. 您可以使用nm工具打印应用程序符号表。 If you search for
swift
, for example using grep
: 如果你搜索
swift
,例如使用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. 对于100%Objective-C应用程序,结果将为空。 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.
但是,您无法判断代码是否为100%Swift,因为对于混合的objc + swift应用程序,结果将类似于swift应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.