You can daemonize any swift process.
Daemon
can detach your swift script from shell.
import Foundation
import Daemon
DispatchQueue(label: "foo").async {
while true {
print(".")
sleep(1)
}
}
Daemon.daemonize()
while true {
sleep(1)
}