Using SPM Shell completion script in oh-my-zsh


I'd like to leverage shell completion script in oh-my-zsh

I added the script with swift package completion-tool generate-zsh-script > ~/.oh-my-zsh/completions/_swift

But when I try auto-completion, e.g. for 'swift package', then I get the error swift:273: parse error near ()

Any suggestions?

Thanks in advance,

Looks to me that that issue is not specific to using the script in oh-my-zsh but rather that the ZSH completion script was incorrectly generated. Probably a bug of SPM.

This manually modified version of the generated script works for me:

I fixed the bug with fix completion script generation by MarcoEidinger · Pull Request #5852 · apple/swift-package-manager · GitHub

I also created feat(swiftpm): update completion for Swift 5.7 by MarcoEidinger · Pull Request #11299 · ohmyzsh/ohmyzsh · GitHub to add working 5.7 completion script to ohmyzsh