Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift code to class diagram

Tags:

swift

uml

Is there a way to generate UML Class diagram for swift programming language? I found that the Mac A&D tool claims to be able to scan the swift code and create a class diagram. And there is a video to introduce it. https://wn.com/swift_code_to_class_diagram

Unfortunately, it is not free. I wonder if there is another free tool to generate class diagram automatically. Could you guys help me? Thanks in advance.

UML class diagrams for Xcode (swift programming)

like image 406
Leaf Avatar asked May 09 '17 07:05

Leaf


People also ask

How do you create a class diagram code?

To generate code from class diagram: Right click on the class diagram background and select Utilities > Java Round-trip > Generate Code from the popup menu. In the Generate Code dialog box, specify the source path where you want the code to be generated.

How do I create a class diagram in Xcode?

There's a handy feature to create class diagrams in Xcode, using Class Model feature. To create a diagram for the whole project, select the project name in the Group & Files panel. Then select Menu->Design->Quick Model->Class Model.

How do you connect class diagrams?

To show a composition relationship in a UML diagram, use a directional line connecting the two classes, with a filled diamond shape adjacent to the container class and the directional arrow to the contained class.


1 Answers

There are a number of free and open-source tools but those often require the user to manually install additional dependencies (e.g. NodeJS, Graphviz or Python). Some of the projects are no longer maintained and are limited when it comes to functionality. And none of these tools were written in Swift.

So I started to work on such utility myself.

Xcode extension: https://github.com/MarcoEidinger/SwiftPlantUML-Xcode-Extension

You are able to generate a class diagram from selected lines of code or from a whole file displayed in Xcode. The class diagram will then be opened in your browser. There you can modify the diagram with PlantUML notation

To generate a class diagram from multiple source files you can use the underlying CLI tool and Swift Package: https://github.com/MarcoEidinger/SwiftPlantUML

There is a size limitation to the visible diagram content (but you can delete content in the browser with PlantUML notation)

like image 58
Marco Eidinger Avatar answered Nov 16 '22 00:11

Marco Eidinger