Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
chore: make quick installs tweak changes and asks for a full install when needed
My-Name-Is-Jeff6798f7480a23
diff --git a/.gitignore b/.gitignoreindex 3909ea0c..35a91f71 100644--- a/.gitignore+++ b/.gitignore@@ -22,3 +22,6 @@ vendor/*/build/# Local research and clean-room specs, kept with the repo but never published.notes/++# zsign's signature cache, from signing out/quick/ in place+.zsign_cache/diff --git a/Makefile b/Makefileindex 0d9b23c5..fc93fa22 100644--- a/Makefile+++ b/Makefile@@ -12,13 +12,15 @@ FLEX_ARG := $(if $(filter 0,$(FLEX)),--no-flex,)DEV_NAME ?= spoti.devDEV_ICON ?= docs/icon.png-.PHONY: build release install trees session log flags+.PHONY: build release install quick trees session log flagsbuild: ## FLEX + glass IPA into out/./scripts/pipeline.sh $(IPA)release: ## glass only, no FLEX./scripts/pipeline.sh $(IPA) --no-flexinstall: ## build, sign with your certificate, push to the phone on USB (FLEX=1 to take FLEX too)./scripts/pipeline.sh $(IPA) --install $(FLEX_ARG) --name "$(DEV_NAME)" --icon "$(DEV_ICON)" -o out/spoti.dev.ipa+quick: ## a tweak-only change into the app the last build made: rebuild, sign, install in seconds+ ./scripts/quick.shtrees: ## record per-screen view trees into trees/ (needs a FLEX build on the phone)./scripts/record-trees.pysession: ## record clean trees screen by screen into trees/clean/, Enter per snapshot, n for the next screen (SCREENS="playlist artist" for some)diff --git a/scripts/install.sh b/scripts/install.shindex 0495e77e..73b8815f 100755--- a/scripts/install.sh+++ b/scripts/install.sh@@ -1,13 +1,14 @@#!/usr/bin/env bash-# Signs an IPA with your own certificate and installs it on the iPhone plugged into this Mac.+# Signs an IPA, or an app folder, with your own certificate and installs it on the paired iPhone, over USB+# or the network, through Xcode's devicectl.## scripts/install.sh out/<name>.ipa+# scripts/install.sh out/quick/Payload/Spotify.app # signed in place; scripts/quick.sh does this## Put the certificate details in .signing.env (gitignored):# SIGN_P12=/path/to/cert.p12# SIGN_PROFILE=/path/to/profile.mobileprovision# SIGN_P12_PASSWORD=...-# WIFI=1 installs over Wi-Fi instead of USB (the phone must be paired for wireless sync).set -euo pipefailROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"@@ -15,11 +16,11 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"cd "$ROOT": "${SIGN_P12:?set SIGN_P12 in .signing.env}" "${SIGN_PROFILE:?set SIGN_PROFILE in .signing.env}" "${SIGN_P12_PASSWORD:?set SIGN_P12_PASSWORD in .signing.env}"-IN="${1:?usage: $0 <ipa>}"-SIGNED="${IN%.ipa}-signed.ipa"+IN="${1:?usage: $0 <ipa or .app folder>}"+# A folder is signed where it is, and zsign then re-signs only what changed since its last signing.+if [ -d "$IN" ]; then SIGNED="$IN"; else SIGNED="${IN%.ipa}-signed.ipa"; ficommand -v zsign >/dev/null || { echo "missing zsign -> brew install zsign" >&2; exit 1; }-command -v ideviceinstaller >/dev/null || { echo "missing ideviceinstaller -> brew install ideviceinstaller" >&2; exit 1; }# The bundle id has to equal the App ID of the profile. iOS may well install a mismatched pair, but# MediaRemote launches the now playing app by its application-identifier entitlement rather than by@@ -33,7 +34,11 @@ APP_ID="${APP_ID#*.}"sign() { # sign [bundle id]echo "==> signing${1:+ as $1}"- zsign -k "$SIGN_P12" -p "$SIGN_P12_PASSWORD" -m "$SIGN_PROFILE" ${1:+-b "$1"} -z 1 -o "$SIGNED" "$IN" >/dev/null+ if [ -d "$IN" ]; then+ zsign -k "$SIGN_P12" -p "$SIGN_P12_PASSWORD" -m "$SIGN_PROFILE" ${1:+-b "$1"} "$IN" >/dev/null+ else+ zsign -k "$SIGN_P12" -p "$SIGN_P12_PASSWORD" -m "$SIGN_PROFILE" ${1:+-b "$1"} -z 1 -o "$SIGNED" "$IN" >/dev/null+ fi}if [ -n "$APP_ID" ] && [ "$APP_ID" != "*" ]; then sign "$APP_ID"; else sign; fi@@ -43,8 +48,7 @@ phone() { xcrun devicectl list devices 2>/dev/null | awk '/physical/ && /iPhone/# An install waits on the app while it runs, so a copy already on the phone is quit first.quit_app() {[ -n "$APP_ID" ] && [ "$APP_ID" != "*" ] || return 0- local udid apps procs pid- udid="$(phone)"; [ -n "$udid" ] || return 0+ local udid="$UDID" apps procs pidapps="$(mktemp)"; procs="$(mktemp)"xcrun devicectl device info apps --device "$udid" --bundle-id "$APP_ID" --json-output "$apps" >/dev/null 2>&1 || truexcrun devicectl device info processes --device "$udid" --json-output "$procs" >/dev/null 2>&1 || true@@ -64,18 +68,9 @@ PYxcrun devicectl device process terminate --device "$udid" --pid "$pid" >/dev/null 2>&1 || true}+UDID="$(phone)"+[ -n "$UDID" ] || { echo "no paired iPhone over USB or the network" >&2; exit 1; }quit_app-echo "==> installing $SIGNED"-# USB through libimobiledevice when a cable is in, given three minutes, since it can stall for good partway;-# otherwise, or after a stall, Xcode's devicectl, which reaches a paired phone over USB or Wi-Fi.-limited() { if command -v timeout >/dev/null; then timeout 180 "$@"; else "$@"; fi; }-usb=; { [ -n "$(idevice_id -l)" ] || [ -n "${WIFI:-}" ]; } && usb=1-if [ -n "$usb" ] && out="$(limited ideviceinstaller ${WIFI:+-n} install "$SIGNED" 2>&1)"; then- printf '%s\n' "$out" | tail -3-else- if [ -n "$usb" ]; then echo "==> ideviceinstaller stalled or failed, using devicectl"; fi- UDID="$(phone)"- [ -n "$UDID" ] || { echo "no iPhone over USB or the network" >&2; exit 1; }- echo "==> installing through devicectl to $UDID"- xcrun devicectl device install app --device "$UDID" "$SIGNED" 2>&1 | grep -E "installationURL|error|Error" | tail -3-fi+echo "==> installing $SIGNED to $UDID"+out="$(xcrun devicectl device install app --device "$UDID" "$SIGNED" 2>&1)" || { printf '%s\n' "$out" | grep -iE "error|reason|description" | head -5 >&2; exit 1; }+printf '%s\n' "$out" | grep -E "installationURL" | tail -1diff --git a/scripts/quick.sh b/scripts/quick.shnew file mode 100755index 00000000..029f5ed0--- /dev/null+++ b/scripts/quick.sh@@ -0,0 +1,59 @@+#!/usr/bin/env bash+# Rebuilds the tweak alone and installs it in the app the last full build made: seconds of compiling and+# signing instead of minutes of unpacking, injecting and zipping.+#+# scripts/quick.sh (make quick)+#+# The last out/*.ipa from scripts/pipeline.sh is kept unpacked in out/quick/, and unpacked again when a+# newer one is built. Only spotifyglass.dylib changes: a change to the extension, the App Group shim, a+# plist or an icon needs the full pipeline (make install).+set -euo pipefail++ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"+CACHE="$ROOT/out/quick"+IPA="$(ls -t "$ROOT"/out/*.ipa 2>/dev/null | grep -v -- '-signed\.ipa$' | head -1 || true)"+[ -n "$IPA" ] || { echo "no IPA in out/: run the full build once (make install)" >&2; exit 1; }++# What only the full pipeline builds: the Live Activity widget (its Swift, some of it beside the tweak's+# sources), the App Group shim, the plist overlay and the icons. Changed since that build, it is stale here.+stale="$(find "$ROOT/extension" "$ROOT/plist" "$ROOT/icons" "$ROOT/tweak/Sources" \( -name '*.swift' -o -path "$ROOT/extension/*" -o -path "$ROOT/plist/*" -o -path "$ROOT/icons/*" \) -type f -newer "$IPA" 2>/dev/null | head -3)"+if [ -n "$stale" ]; then+ printf 'changed since the last full build, which make quick does not rebuild:\n%s\nrun make install once\n' "$stale" >&2+ exit 1+fi++if [ ! -f "$CACHE/.from" ] || [ "$IPA" -nt "$CACHE/.from" ] || [ "$(cat "$CACHE/.from")" != "$IPA" ]; then+ echo "==> unpacking $IPA"+ rm -rf "$CACHE"+ mkdir -p "$CACHE"+ unzip -q "$IPA" -d "$CACHE"+ # The App Store's DRM records, which a decrypted app does not need, and which make the phone refuse the+ # patch install devicectl does for a folder ("did not supply a new SINF").+ find "$CACHE/Payload" -type d -name SC_Info -prune -exec rm -rf {} ++ printf '%s' "$IPA" > "$CACHE/.from"+fi+APP="$(ls -d "$CACHE"/Payload/*.app | head -1)"++# A build with FLEX carries the phone driver (tweak/Makefile, SG_DRIVER). Theos rebuilds by file times+# alone, so a change of the flag cleans first.+DRIVER=0+[ -f "$APP/Frameworks/autoflex.dylib" ] && DRIVER=1+STAMP="$ROOT/tweak/.theos/quick-driver"+if [ "$(cat "$STAMP" 2>/dev/null)" != "$DRIVER" ]; then+ echo "==> SG_DRIVER is now $DRIVER: building from clean"+ env -u MAKELEVEL gmake -C "$ROOT/tweak" clean >/dev/null+fi++# The linked dylib is taken from Theos's objects, with no .deb packed around it.+echo "==> building tweak"+env -u MAKELEVEL gmake -C "$ROOT/tweak" SG_DRIVER="$DRIVER" >/dev/null+mkdir -p "$(dirname "$STAMP")"+printf '%s' "$DRIVER" > "$STAMP"++# The dylib as cyan puts it in the app: Substrate found through the app's Frameworks.+DYLIB="$APP/Frameworks/spotifyglass.dylib"+cp "$ROOT/tweak/.theos/obj/spotifyglass.dylib" "$DYLIB"+install_name_tool -change /Library/Frameworks/CydiaSubstrate.framework/CydiaSubstrate \+ @rpath/CydiaSubstrate.framework/CydiaSubstrate "$DYLIB" 2>/dev/null++exec "$ROOT/scripts/install.sh" "$APP"diff --git a/tweak/Makefile b/tweak/Makefileindex fcf49958..ef41166a 100644--- a/tweak/Makefile+++ b/tweak/Makefile@@ -1,6 +1,9 @@TARGET := iphone:clang:latest:16.0ARCHS := arm64FINALPACKAGE := 1+# Logos's .x.m output is kept: an .x object depends on it, and Theos otherwise deletes it after compiling,+# so every .x file would compile again on every build.+KEEP_LOGOS_INTERMEDIATES := 1# version.txt at the repo root is the one version, bumped by Release Please's release PR. Theos# stamps PACKAGE_VERSION into the .deb (control has no Version line) and reads it while common.mk