d.ennis
d.ennis

Reputation: 3455

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.

Upvotes: 3

Views: 250

Answers (4)

Giulia Nicole Pernice
Giulia Nicole Pernice

Reputation: 763

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.

Upvotes: 2

PeyloW
PeyloW

Reputation: 36752

Two good places to start looking are always;

  1. Is there a MainWindow.nib file, in that case you can see how the view controller hierarchy is setup.
  2. Search for the applicationDidFinishLaunching:withOptions: delegate method, this is where it all starts.

From there it's all about finding good places for break points.

Upvotes: 1

ader
ader

Reputation: 5393

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.

Upvotes: 2

jrturton
jrturton

Reputation: 119272

I'm assuming you are already familiar with iOS and its libraries. If not, that would be your first step.

You won't necessarily get much of use from class dumps or UML as a lot of calls aren't explicitly made from within the code that you will see - I'm thinking of delegate methods in particular.

I'd start with the nib files or storyboards. Follow the navigation through the app - start with the first screen the user sees and work down each possible branch of the tree. Most of the logic that responds to what the user can do will be inside the viewcontroller subclass or linked to the UI objects in interface builder.

The data model, if present, should be capable of being understood without needing to refer to any of the code. Get your head around that and see how it relates to the flow of the UI.

Upvotes: 1

Related Questions