I have this setup in my Ubuntu .vimrc. I don't see any swap files in my project files.
set undofile
set undolevels=1000 " How many undos
set undoreload=10000 " number of lines to save for undo
set backup " enable backups
set swapfile " enable swaps
set undodir=$HOME/.vim/tmp/undo " undo files
set backupdir=$HOME/.vim/tmp/backup " backups
set directory=$HOME/.vim/tmp/swap " swap files
" Make those folders automatically if they don't already exist.
if !isdirectory(expand(&undodir))
call mkdir(expand(&undodir), "p")
endif
if !isdirectory(expand(&backupdir))
call mkdir(expand(&backupdir), "p")
endif
if !isdirectory(expand(&directory))
call mkdir(expand(&directory), "p")
endif