Git Product home page Git Product logo

paultaykalo / objc-dependency-visualizer Goto Github PK

View Code? Open in Web Editor NEW
1.8K 48.0 103.0 1.83 MB

Objective-C and Swift dependency visualizer. It's tool that helps to visualize current state of your project. It's really easy to see how tight your classes are coupled.

License: MIT License

JavaScript 94.62% CSS 0.69% Ruby 4.35% HTML 0.34% Shell 0.01%
dependency dependency-graph dependency-tree structure swift objective-c graph d3js swift-dependencies-visualizer javascript

objc-dependency-visualizer's Introduction

Objective-C And Swift Dependencies Visualizer

Build Status

This is the tool, that can use .o(object) files to generate dependency graph.
All visualisations was done by d3js library, which is just awesome!
This tool was made just for fun, but images can show how big your project is, how many classes it have, and how they linked to each other

Image example

Easiest way - For those who don't like to read docs

This will clone project, and run it on the latest modified project

git clone https://github.com/PaulTaykalo/objc-dependency-visualizer.git ;
cd objc-dependency-visualizer ;
./generate-objc-dependencies-to-json.rb -d -s "" > origin.js ;
open index.html

Easiest way for Swift projects

git clone https://github.com/PaulTaykalo/objc-dependency-visualizer.git ;
cd objc-dependency-visualizer ;
./generate-objc-dependencies-to-json.rb -w -s "" > origin.js ;
open index.html

More specific examples

Examples are here

Tell the world about the awesomeness of your project structure

Share image to the Twitter with #objcdependencyvisualizer hashtag

Hard way - or "I want to read what I'm doing!"

Here's detailed description of what's going on under the hood

objc-dependency-visualizer's People

Contributors

0xced avatar bitdeli-chef avatar dhcdht avatar paultaykalo avatar vixentael avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

objc-dependency-visualizer's Issues

Can not generate index.html for Swift project

I'm using command from your tutorial:

./generate-objc-dependencies-to-json.rb -w -s "" > origin.js ;

However if fails with the following output:

mbpzen:objc-dependency-visualizer zen$ ./generate-objc-dependencies-to-json.rb -w -s "" > origin.js ;
find: /Users/zen/Library/Caches/appCode*/DerivedData: No such file or directory
There were 302 directories found
Last modifications were in
/Users/zen/Library/Developer/Xcode/DerivedData/NDA-azxrhxscylnfwqhifbyzbosmrwfi/Build/Intermediates/NDA.build/Debug-iphonesimulator/NDA.build/Objects-normal/x86_64
directory at
2015-10-22 00:02:09 +0300
Cannot read file  /Users/zen/Library/Developer/Xcode/DerivedData/NDA-azxrhxscylnfwqhifbyzbosmrwfi/Build/Intermediates/NDA.build/Debug-iphonesimulator/NDA.build/Objects-normal/x86_64/NDA-master.swiftdeps : This is possibly because output file was changed:(/Users/zen/Library/Developer/Xcode/DerivedData/NDA-azxrhxscylnfwqhifbyzbosmrwfi/Build/Intermediates/NDA.build/Debug-iphonesimulator/NDA.build/Objects-normal/x86_64/NDA-master.swiftdeps): found character that cannot start any token while scanning for the next token at line 5 column 1

Error when running project

I get this error when running the suggested command:
/Users/<MY_HOME_DIRECTORY>/Library/Caches/appCode*/DerivedData: No such file or directory
There were 0 directories found
Cannot find projects that starts with 'MY_PROJECT_NAME'

Does it support h5 page?

I try to run the index.html in safari ios simulator, seems need to optimize something on display.

origin.js is empty

I have a pod project named kepler4iphone
and I user your tool to execute scentence like below:

1、clone it into my folder
2、execute ./generate-objc-dependencies-to-json.rb -d -s "kepler4iphone" > origin.js ;
console shows:
find: /Users/frank/Library/Caches/appCode*/DerivedData: No such file or directory
There were 24 directories found
Last modifications were in
/Users/frank/Library/Developer/Xcode/DerivedData/kepler4iphone-fpjlrpkkpaulyydolpctvygupltl/Build/Intermediates.noindex/Pods.build/Debug-iphoneos/WeexResKit.build/Objects-normal/armv7
directory at
2018-09-12 12:15:24 +0800

3、nothing in origin.js

How do I debug a Swift dependency tree analysis?

Hi, love the gem, works like magic with a brand new Swift project but when I run the script for an existing production codebase I get the following output in origin.js

var dependencies = {"links":[],"links_count":0,"objects":{}}

Seems like nothing gets parsed and I wonder why and how would debug this?

Also is there a way to run it for an arbitrary folder with Swift code?

[question] Draw boundaries of program units

Is there any way to mark the class circles as belonging to a certain library?
It would be nice to have a rectangle around the group of classes from the same unit. Or, at least, mark them with the same colour.

The distinction may be done by either

  1. prefix (NS/AF/etc.) - for cocoapods based repositories
  2. target - for static lib/sub-project based repositories

Can't Read .swiftdeps ?

When I run
./generate-objc-dependencies-to-json.rb -w -s "swift-project-analyzer"

I get the following error

Cannot read file /Users/xinyi/Library/Developer/Xcode/DerivedData/OnePlayer-cqtdohbytzcdggcjripigujhpuhx/Build/Intermediates.noindex/OnePlayer.build/Debug-iphonesimulator/OnePlayer.Example.SwiftUI.build/Objects-normal/x86_64/SwiftUIOnePlayerViewModel.swiftdeps : This is possibly because output file was changed:(/Users/xinyi/Library/Developer/Xcode/DerivedData/OnePlayer-cqtdohbytzcdggcjripigujhpuhx/Build/Intermediates.noindex/OnePlayer.build/Debug-iphonesimulator/OnePlayer.Example.SwiftUI.build/Objects-normal/x86_64/SwiftUIOnePlayerViewModel.swiftdeps): control characters are not allowed at line 1 column 1

File-level Dependencies

Is there some way to group everything by file, rather than also showing the individual types etc.? I just want to think about my dependencies at the file level.

No graph is generated.

Hello.

I have a problem with the plugin. I installed it correctly. Runs correctly and generates me the files, but when I open the file "index" in the browser, there is no graphic inside.

I tried with several Xcode projects, but nothing changes.

My Xcode version is 6.1.1

Use custom path to DerivedData

If DerivedData is relative to project, visualizer tool doesn't find it.
relative-path

I usually have error like:

➜ ./generate-objc-dependencies-to-json.rb -d -s "" > origin.js ;
find: ~/Library/Caches/appCode*/DerivedData: No such file or directory
There were 0 directories found
Cannot find projects that starts with ''

In this case I need to pass as parameter full path for object files, like this:

./generate-objc-dependencies-to-json.rb -d -p "~/projects/<FOLDER_NAME>/ios-project/DerivedData/<PROJECT_NAME>/Build/Intermediates/<PROJECT_NAME>.build/Debug-iphoneos/<PROJECT_NAME>.build/Objects-normal" > origin.js

I think that it's quite inconvenient. Let's add param to pass path to DerivedData folder like this:

./generate-objc-dependencies-to-json.rb -d -D "~/projects/<FOLDER_NAME>/ios-project/DerivedData" > origin.js

where D stands for DerivedData

Allow to group classes by domains

Often we don't want' to see dependencies on the classes itself, but rather to check, if our abstractions are leaking or not.

For example in MVVM - View should not be pointing to Model, ViewModel should not know anything about View and Model should not know anything about ViewModel.

So there should be a way how to show it correctly )

Generate graphs for framework targets

Hi,

Great tool, I can easily generate graphs for test and project targets.

However, is there a way to do the same for framework targets?

It seems like your code always checks the simulator but the frameworks are never run on the simulator.

Thanks

Does it work for Xcode 8.3.2?

I tried my project and some public project i.e Alamofire. But it does not generate anythings.

Console:

./generate-objc-dependencies-to-json.rb -d -s "" > origin.js ; open index.html
find: /Users/username/Library/Caches/appCode*/DerivedData: No such file or directory
There were 91 directories found
Last modifications were in
/Users/username/Library/Developer/Xcode/DerivedData/Alamofire-dhtndbmjkaofkwemgqqalpcgngke/Build/Intermediates/Alamofire.build/Debug/Alamofire macOS.build/Objects-normal/x86_64
directory at
2017-05-19 18:38:31 +1000

Exclude nodes that don't have outgoing edges

In large projects with many classes this graph can get quite messy. It would help if there was an option to eliminate nodes that only have one incoming edge and no outgoing ones.

Separate tree building and filtering phases

Currently dep viz tries to perform all the things by getting dependencies, filtering items
But it's possible that we can use intermediate dependencies file (as .JSON) and perform post filering by another phase. this will help to perform fast filtering of some system libraries and some unneded classes without the need to regenerate the tree again

This also can be done to regenerate inheritance only graph

  • generate intermediate output (unfiltered json)
  • allow to use (unfiltered json) as a source and only apply filtering to it
  • allow to use multiple jsons and merge them

There were 45 directories found error

I'm unable to generate a graph for any project.

Reproduce

  1. Downloaded KSHMosaicCamera
  2. Built and ran the project
  3. From the visualizer folder, ran: ./generate-objc-dependencies-to-json.rb -s "" -D /Users/peter/Library/Developer/Xcode/DerivedData/ > origin.js
    (note, without the -D I get the error: find: /Users/peter/Library/Caches/appCode*/DerivedData: No such file or directory)

Expected

The graph generates

Actual

Output is:

There were 45 directories found
Last modifications were in
/Users/peter/Library/Developer/Xcode/DerivedData/MosiacCamera-gdvravkbpqymxvesgqnomlgzenbe/Build/Intermediates.noindex/MosiacCamera.build/Debug-iphonesimulator/MosiacCamera.build/Objects-normal/x86_64
directory at
2018-01-05 17:48:48 -0800

I'm on Xcode Version 9.2 (9C40b). Is there anything I'm doing wrong?

FYI, here's my derived data setup:
screen shot 2018-01-05 at 5 52 40 pm

Thanks for your help. This tool seems really useful.

[feature] Multiple obj files location support

As a sub-project approach user
I'd like to specify multiple location of _.obj files
_So that* business logic files contained in a sub-project is displayed in the graph.

It would be cool to easily switch between the "single project" mode (as is) and "all *.obj files in DerivedData" to get the desired level of report granularity.

How to filter categories?

The README says that you can filter classes and I found the removal of certain prefixes, but is it also possible to filter out categories from the dependency graph?

Aside from that: Outstanding tool, really appreciate your work!

Provide ability to input part of Project name

Since, there's already should be some compiled projects on the computer, may be it's good idea to search through Derived data directories in order to be able to choose project from command line instead of specifying loooong path string

origin.js file does not seem to be closed correctly

Environment: OS X 10.11.2

The origin file does not seem to be closed in the end. OS X Finder shows the file with a size of zero bytes after running the script. Duplicating the origin.js in Finder rectifies this.

Doesn't run except by polluting the app's folder

Great tool, but it seems (From following instructions) that it's configured to only work when you stick the entire project inside your repository, inside your app's folder / xcodeproj - which then pollutes the xcode project (xcode will now see the files, which is very much not what I'd expect/want).

e.g. if I try to run generate-objc-dependencies-to-json.rb from the project folder, it crashes because it's hard-coded to ignore where the script lives, and instead use the current folder as the location for the visualizers binaries. I get, for instance:

ruby: No such file or directory -- ./bin/objc_dependency_tree_generator (LoadError)

e.g. if I try to run generate-objc-dependencies-to-json.rb from its own folder, and tell it where the project is located ... well, I can't. There's no command line option for that.

Dot

I have some issue, when trying to use -f dot format.
After the generation competes I got:

digraph dependencies {
	node [fontname=monospace, fontsize=9, shape=box, style=rounded]
	"" -> ""
// ...
	"" -> ""
}

I've investigate a little and found that the solution is to change the line
https://github.com/PaulTaykalo/objc-dependency-visualizer/blob/master/lib/tree_serializer.rb#L58
which is now:

s += "#{indent}\"#{link['source']}\" -> \"#{link['dest']}\"\n"

to the line:

s += "#{indent}\"#{link[:source]}\" -> \"#{link[:dest]}\"\n"

So using of symbols instead of string to query link helps.
I don't now rube well, so I'm not sure that it's right solution.

Swift dependency visualizer not working

Xcode 13.1
Here is the result after running the line:
Screen Shot 2021-12-29 at 12 34 41 AM
First of all, it's a large project, it should be way more than 5 "directories".
Second of all, index.html is empty.
Please help.

Visualize dependencies in development pod

Hi, I would like to visualize dependencies in a swift pod. Is there a way?

I tried:

  1. pod lib create HelloLib, choose Swift
  2. cd HelloLib
  3. open Example/HelloLib.xcworkspace
  4. Add logic in Development Pod and use the lib in the demo app. For example, in Development Pod add:
  • public class HelloLib { let dummy = Dummy(); public func doNothing() { dummy.doNothing() }}
  • class Dummy { func doNothing() {}}
  • then, in AppDelegate, import HelloLib and call HelloLib().doNothing()
  • build the example app
  1. git clone https://github.com/PaulTaykalo/objc-dependency-visualizer.git
  2. cd objc-dependency-visualizer
  3. ./generate-objc-dependencies-to-json.rb -w -s "" > origin.js

Index.html shows (as expected) AppDelegate, ViewController and HelloLib but no sign of Dummy.

Regards

Improve the readme

Hey Paul!

I was a bit afraid of going through all the steps, I think you could make the read me even better by showing how easy it is and only including the clone/run script/etc. And then all the other manual steps could be on the wiki or in a different file. Because at first glance, you don't see how easy this is =)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.