At my child's high school, phones are "off and away all day", and the punishment for being caught with a phone in your pocket (or hands) is pretty severe.
During an exam, it's an instant zero mark, on top of the after-school detention (the punishments escalate to suspension and expulsion for repeat offenses).
The same method that any test given in the last 150 years has done to prevent people from using cheat sheets or similar, by having roaming proctors in the room? Or policies like certain models of HP or TI graphing calculator only allowed on the table, for the sort of test that requires one...
I have had a couple exams in university where it was explicitly allowed to bring a (handwritten) A4 cheat sheet. Depends what you are testing though - understanding or memorization.