Skip to content

Instantly share code, notes, and snippets.

@WFT
Last active December 22, 2016 19:42
Show Gist options
  • Save WFT/2ac380226335d61e7695bfeb79554baf to your computer and use it in GitHub Desktop.
Save WFT/2ac380226335d61e7695bfeb79554baf to your computer and use it in GitHub Desktop.
Opens a file in the iOS simulator using a file URL.
#!/bin/bash
set -e
if [[ $# -eq 1 || $# -eq 2 ]]; then
url="file://$(realpath "$1" | sed 's/ /%20/g')"
xcrun simctl openurl ${2:-booted} "$url" ||
echo "$url" could not be opened
else
echo "USAGE: $0 PATH [SIM_NAME]"
echo "Opens a file in the iOS simulator using a file URL."
echo "Defaults to the 'booted' simulator."
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment