Hi Olive,
If someone 'swears by' something is means they really believe in it, or that it works. For example, I love running in the morning because it's healthy - I swear but it. Or, I like to add sugar to my coffee because it tastes better sweet, so I swear by sugar "it".
English is confusing, I know. But, in the end, to 'swear by something' just means you really believe it and want others to know so.
Take care, Olive. :)