Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best Approach: Read And Understand Unknown Xcode Projects

I have a large Xcode project with only inline documentations, written by someone who has a very different coding style as I am used to.

My Question now is, if someone could give me something like a guideline on how to read and understand unknown Xcode projects as fast as possible?


What I tried:

First I ran the app. Then I tried to get threw the project method calls one by one starting (in the case of iOS) from the application:didFinishLaunchingWithOptions: delegate method. But soon I realized, that this will consume too much time. So I tried to use some tools: I generated an UML graph with a tool called Graffle. It generated a flat graph with all Xcode files in it very similar to what they look like in the project navigator - which didn't help at all. Then I tried to find a call-graph tool which hopefully illustrates all interactions of the written methods. Unfortunately I only found tools for other platforms. Then I started to use Instruments Profiler but never got to a point where it really helped me (maybe also because I didn't understand how to use it right for my approach).

So again, I would like to know how you specialists work yourself (step by step) threw an objective-c code you didn't write? Any links, book recommendations, sample test-codes, or others are greatly welcome as well. Thanks.

like image 338
d.ennis Avatar asked Jan 22 '26 01:01

d.ennis


2 Answers

Firstly, I sympathize greatly. Sometimes understanding another's code takes longer than re-writing your self.

Personally, I would put NSLog statements at the start of all relevant methods. I would then starting at the applicationDidFinishLaunching comment out method calls trying to get the app to work step by step and gradually re-enable method by method.

like image 72
ader Avatar answered Jan 24 '26 13:01

ader


In addition to the above suggestions, as a free tool, you could try Doxygen: www.doxygen.com

The output can include:

  • hyperlinked source code (click an identifier -> shows its definition)
  • header dependencies (includes & included-by graphs)
  • function call dependencies (links to all calls to a function)
  • class hierarchies (graphs, links)
  • index of namespaces, class names, etc...

You could also give a spin to JetBrains AppCode (30-days trial): www.jetbrains.com

it aims to help in code assistance, navigation, analysis, transformation and refactoring.

like image 45
Nicola Giulia Pernice Avatar answered Jan 24 '26 15:01

Nicola Giulia Pernice



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!