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)
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.
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.
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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With