Detected languages are done through a site setting: highlighted languages
.
Swift belongs to the list by default but does not on meta.
The supported languages by this third-party library are listed here:
https://highlightjs.readthedocs.io/en/latest/supported-languages.html
edit: as explained here
@PrettyGirl, markdown tip: you can escape backticks from a codeblock by wrapping your code by four backticks instead of three
``` swift
[code here]
```