Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby parser for obj-c

I'm trying to write a small ruby gem to generate statistics about my Xcode project. I have no problem with file numbers, row numbers and so on, but I want also generate statistics about the number of methods, number of classes etc.

There is some kind of obj-c parser written in Ruby? The alternative can be to interact with OCLint executable but I'm scared it will be a lot of work for a small utility.

like image 253
TheObjCGuy Avatar asked Nov 10 '22 14:11

TheObjCGuy


1 Answers

I am not aware of such a publicly-available parser—or grammar for that matter—that represents Obj-C syntax in Ruby.

Here are a couple ways that come to mind to solve your task.

Two Options:

  1. If you're interested in counting certain metadata about files, you can try making a naive, poor-man's "parser" using regular expressions that extract this metadata.

  2. If you're merely interested in the number of methods and such (symbols) of a compiled project, you can use otool or nm to dump symbols (nm will dump global variables as well) of your object (compiled binary).

Not 100% if these tools work on compiled Swift objects


The Commands:

otool -TV <object>
nm -a <object>
like image 122
Sean Avatar answered Nov 15 '22 07:11

Sean