#!/bin/sh # Builds Factorio for iPhone from your local Steam copy, installs it on the connected iPhone and # copies the game data. Safe to run again: data that is already on the phone is skipped and saves # are kept. Extra arguments are passed to tools/build_native.py (see docs/building.md). cd "$(dirname "$0")" || exit 1 mkdir -p build LOG=build/install.log : > "$LOG" fail() { echo echo "Failed: $1" echo "Details are in $LOG" exit 1 } step() { # step "message" args... : run build_native.py with args, logging its output. message=$1; shift printf '%s... ' "$message" if python3 tools/build_native.py "$@" >> "$LOG" 2>&1; then echo "ok" else echo if grep -q "not, or could not be, unlocked" "$LOG"; then fail "device was not unlocked. Unlock the iPhone and run ./install.sh again." fi # build_native.py ends with a one-line explanation of what went wrong. reason=$(grep -v '^+' "$LOG" | grep -v '^\s*$' | tail -n 3) fail "$reason" fi } command -v xcrun > /dev/null 2>&1 || fail "Xcode is not installed (README step 1)." xcrun --sdk iphoneos --show-sdk-path > /dev/null 2>&1 || fail "Xcode's iOS platform is missing (README step 1)." command -v python3 > /dev/null 2>&1 || fail "python3 not found; open Xcode once to finish installing its tools." step "Building the app" "$@" step "Installing on the iPhone" --no-build --install "$@" step "Copying game data to the iPhone (first time takes a few minutes)" --no-build --push-data "$@" echo echo "Done. Open Factorio from the iPhone home screen."