PaulTaykalo / objc-dependency-visualizer

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.
MIT License
1.84k stars 98 forks source link

There were 45 directories found error #54

Closed plivesey closed 6 years ago

plivesey commented 6 years ago

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.

PaulTaykalo commented 6 years ago

It's not like an error, it's more like a warning, because you have never installed AppCode :)

Just run without > origin.js ./generate-objc-dependencies-to-json.rb -s "" -D /Users/peter/Library/Developer/Xcode/DerivedData/

And check the result.

If it's swift project, you can actually try to run with -w flag. Check here https://github.com/PaulTaykalo/objc-dependency-visualizer/wiki/Usage-examples

plivesey commented 6 years ago

Thanks for the quick response. Running this on MosaicCamera again, I get the following result:

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
var dependencies = {"links":[],"links_count":0,"objects":{}}

I saw this before as the content of origin.js. It seems like whatever project I run it on, it returns 0 objects. Is installing App Code a prerequisite?

PaulTaykalo commented 6 years ago

Nope, AppCode is just an alternative. So it this MosaicCamera your project that was being compiled last? Also, what language is it using and what Xcode version are you using? It seems that script cannot find any information about object being used by this project. (No infomration at DervicedData) driectory. You could try to clean up and recompile everything to check again. Should help. Otherwise, I would likely to see what you have in that directiory in DerivedData sript mentioning

PaulTaykalo commented 6 years ago

Hm.. it seems that is something broken at the moment. Will take a look, and will update you with results

PaulTaykalo commented 6 years ago

Heh. Fixed in https://github.com/PaulTaykalo/objc-dependency-visualizer/commit/4a4800b8c253ef81e43d74a4127bb3c9d8d6fe6c

You can try on your version by running it with ./generate-objc-dependencies-to-json.rb -o ""

or get the latest one from master

plivesey commented 6 years ago

I think the same bug also exists for swift projects? Maybe not the same bug, but getting the same result:

  1. Downloaded alamofire
  2. Compiled alamofire
  3. $ ./generate-objc-dependencies-to-json.rb -w -s "" -D /Users/peter/Library/Developer/Xcode/DerivedData/ > origin.js
    There were 51 directories found
    Last modifications were in
    /Users/peter/Library/Developer/Xcode/DerivedData//Alamofire-gnorjikcilpwaaejyxitgvrwfeyk/Build/Intermediates.noindex/Alamofire.build/Debug/Alamofire macOS Tests.build/Objects-normal/x86_64
    directory at
    2018-01-09 10:28:50 -0800

    But origin.js was empty. It seems like it doesn't currently work on swift projects?

PaulTaykalo commented 6 years ago

It looks for objects in tests target. You should make sure that it looks to the main target instead, You'll need to either rebuild main target, or pass precise directory with object files via -p

plivesey commented 6 years ago

Yep, that was it. I wasn't able to find the object files before, but found it now. Thanks.