Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/marcoeidinger/swiftplantuml-xcode-extension

Xcode Extension for generating class diagrams from Swift code (powered by PlantUML)
https://github.com/marcoeidinger/swiftplantuml-xcode-extension

macos osx planttext plantuml plantuml-generating swift xcode xcode-extension xcode-plugin xcode-source-editor-extension

Last synced: about 3 hours ago
JSON representation

Xcode Extension for generating class diagrams from Swift code (powered by PlantUML)

Awesome Lists containing this project

README

        


SwiftPlantUML

![Build](https://github.com/MarcoEidinger/SwiftPlantUML-Xcode-Extension/workflows/Build/badge.svg)
[![Swift 5.3](https://img.shields.io/badge/swift-5.3-orange.svg?style=flat)](#)
[![Twitter](https://img.shields.io/badge/[email protected])](http://twitter.com/MarcoEidinger)
# SwiftPlantUML.app

Generate and view a class diagram for Swift code in Xcode or from the Finder.

Use the hosting macOS application to configure the diagram visualization.

The Source Editor Extension (as well as the Action extension) makes use of [`SwiftPlantUML`](https://github.com/MarcoEidinger/SwiftPlantUML) Swift package.

To generate a large diagram from a project with Swift files across folders then I recommend using `SwiftPlantUML` as a command-line tool.

## Features

### Xcode
- [X] 📊 Create class diagram from Swift file
- [X] 🔦 Create class diagram from selected Swift code

![SwiftPlantUML Xcode Extension - Usage Demo](.assets/usage.gif)

### Finder
- [X] 📊 Create class diagram from selected Swift file(s)

https://user-images.githubusercontent.com/4176826/218329052-b03ec650-d845-46a2-a31b-6d3817add52a.mp4

## Example

![SwiftPlantUML Xcode Extension - Usage Demo](.assets/usage.gif)

## Install

Homebrew

```bash
brew install swiftplantumlapp
```

Installation through Homebrew

*Alternative*
- Download latest *SwiftPlantUML* package from the [Releases](https://github.com/MarcoEidinger/SwiftPlantUML-Xcode-Extension/releases).
- Copy *SwiftPlantUML* to your *Applications* folder.

## Enable Extension
- Launch *SwiftPlantUML*.

SwiftPlantUML user interface

- To use in **Xcode**: enable extension in System Preferences > Extensions > Xcode Source Editor > select SwiftPlantUML

![SwiftPlantUML Xcode Extension - Installation](.assets/installation.png)

- To use in **Finder**: enable extension in System Preferences > Extensions > Finder > select Open Swift Class Diagram

![SwiftPlantUML Xcode Extension - Installation](.assets/installation.png)

## Configure

*Optional*:

Preferences - Elements

Preferences - Members

Preferences - Others

## Troubleshooting

### The command "Open editable diagram in browser" is still busy

Xcode Source Code Extension initialization might take up ~ 30 seconds on initial launch.

If the prompt does not appear within 60 seconds

![image](https://user-images.githubusercontent.com/37135317/118424310-f77dd000-b701-11eb-9b59-cd3c964e1885.png)

then check for a crash report related to XPC service in Console app of your MacOS.

CrashReportXPCServiceExample

If you see such crash report related to `fatal error: Loading sourcekitd.framework/Versions/A/sourcekitd failed` please check the installation path of Xcode. If it's installed under `/Applications/Xcode.app`, please run:

```
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
```

If it's installed elsewhere, please replace the `/Applications/Xcode.app` path in the command above with the location where you've installed Xcode.

## Technical Details

This Source Editor Extension makes use of XPC service to run the app sandboxed and use `SwiftPlantUML` (and its dependency `SourceKitten`). Source Editor Extensions using `SourceKitten` (either directly or indirectly) have to either run in a non-sandboxed app (and could not be distributed via the App Store) or use XPC service to outsource the use of `SourceKitten` to a different process.

# Acknowledgements

These awesome blog posts helped me to dive into Xcode Source Editor Extensions and XPC services

- https://www.vadimbulavin.com/xcode-source-editor-extension-tutorial/
- https://nshipster.com/xcode-source-extensions/
- https://ilya.puchka.me/xcode-source-editor-extension-superpowered-with-sourcekitten/
- https://www.objc.io/issues/14-mac/xpc/