One way is to give the Tyranid some sort of immunity or reaction to magic. For example, the magic in the Harry Potter world might actually enhance the Tyranid's abilities in some ways, and the characters in the wizarding world have to figure out how to deal with this new and dangerous situation. The combination could also involve the Hogwarts houses having different strategies to fight the Tyranid, like Gryffindors leading the charge while Ravenclaws figure out the Tyranid's weaknesses.
Most likely not. Usually, if a work is based on a true story, that's made clear. But in the case of 'Swarm', there's no indication that it's rooted in reality. It's likely a product of pure imagination and creative writing.
Well, 'Swarm' is not a true story. It's likely the product of the author's imagination and creative writing skills, designed to entertain and engage the audience through fictional scenarios and characters.