I want to send plain text from my MacBook to iPhones.
I can’t get AirDrop to work; I’ve tried selecting the text, right-clicking it, and clicking “Share” but AirDrop doesn’t show up in the sharing menu.
So I am trying to solve this problem the next best way I could think of: making a QR code pop up on the Mac that the phone can scan.
I’ve written a short script that makes that generates and shows a QR code for text passed to stdin:
#!/bin/zsh
workdir=$(mktemp -d)
cd "$workdir"
/usr/local/bin/qrencode -s 10 -o qr.png
qlmanage -p qr.png
(using brew install qrencode
to make the QR code)
This makes a correct QR code for the text, but when the iPhone scans it with the default camera, the only option is to “Search for the text “. I would like to copy/paste the text instead, and not share the text with Google or whatever other search engine.
Maybe I can get Safari to show the text if it is data-URI encoded?
#!/bin/zsh
workdir=$(mktemp -d)
cd "$workdir"
perl -MURI::Escape -e 'local $/; print(uri_escape(<>));' |
sed 's_^_data:text/plain;charset=ISO-8859-1,_' |
/usr/local/bin/qrencode -s 10 -o qr.png
qlmanage -p qr.png
but no luck, now the iPhone says “No usable data found” when it scans the QR code.
I’m pretty sure the data URI is correctly encoded, Safari on my Mac and on my iPhone (after I manually enter them) can open them all, for example
% echo hello\\nthere | perl -MURI::Escape -e 'local $/; print(uri_escape(<>));' | sed 's_^_data:text/plain;charset=ISO-8859-1,_'
data:text/plain;charset=ISO-8859-1,hello%0Athere%0A
and data:text/plain;charset=ISO-8859-1,hello%0Athere%0A
shows the inputted text when you put it into the URL bar in macOS Safari and in iOS Safari.
So my question is, how can I actually most easily transport plain text from macOS to an iOS clipboard? Not the same iCloud/Apple account on both devices.
It would be cool if you can solve the QR code route that I couldn’t, but I’d also be happy to see another solution if it’s as convenient as I imagined the QR one would be (I was going to make it a Quick Action so it would show in the Services menu on the Mac).