diff --git a/App/MulberryApp.swift b/App/MulberryApp.swift index 348a420..afe01f9 100644 --- a/App/MulberryApp.swift +++ b/App/MulberryApp.swift @@ -23,6 +23,10 @@ struct MulberryApp: App { } Theme.shared.update() Player.shared.publishWidget() + Log.i("app: version \(AppVersion.version) (\(AppVersion.build))") + if let note = AppVersion.updateNote() { + DispatchQueue.main.asyncAfter(deadline: .now() + 1.2) { UIState.shared.show(note) } + } } var body: some Scene { diff --git a/App/Services/AppVersion.swift b/App/Services/AppVersion.swift new file mode 100644 index 0000000..802361f --- /dev/null +++ b/App/Services/AppVersion.swift @@ -0,0 +1,17 @@ +import Foundation + +/// Version info from Info.plist (set by build.sh from the VERSION file and the git commit count). +enum AppVersion { + static var version: String { Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "?" } + static var build: String { Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") as? String ?? "?" } + + /// "Updated to x.y.z" once after an update (nil on first install or same version). + static func updateNote() -> String? { + let key = "last_version" + let now = "\(version) (\(build))" + let last = UserDefaults.standard.string(forKey: key) + UserDefaults.standard.set(now, forKey: key) + guard let last, last != now else { return nil } + return "Updated to Mulberry \(version) (build \(build))" + } +} diff --git a/App/UI/RootView.swift b/App/UI/RootView.swift index 020f572..325bf1a 100644 --- a/App/UI/RootView.swift +++ b/App/UI/RootView.swift @@ -118,7 +118,8 @@ struct RootView: View { @EnvironmentObject var prefs: Prefs @EnvironmentObject var scrobbler: Scrobbler @Environment(\.colorScheme) var scheme - @State private var chrome: CGFloat = 80 + /// Measured height of the mini player + nav bar (the start value is a realistic guess, not a minimum). + @State private var chrome: CGFloat = 180 var body: some View { let p = theme.palette @@ -144,8 +145,7 @@ struct RootView: View { } NavBar() } - .background(GeometryReader { g in Color.clear.preference(key: ChromeHeight.self, value: g.size.height) }) - .onPreferenceChange(ChromeHeight.self) { chrome = $0 } + .onGeometryChange(for: CGFloat.self) { $0.size.height } action: { chrome = $0 } if prefs.bassShape && !prefs.lowPower && player.current != nil && !ui.nowPlaying { BassShapeView(playing: player.isPlaying) diff --git a/App/UI/SettingsView.swift b/App/UI/SettingsView.swift index 05a2e40..5cc3d64 100644 --- a/App/UI/SettingsView.swift +++ b/App/UI/SettingsView.swift @@ -107,8 +107,8 @@ struct SettingsView: View { SectionLabel(text: "About") Card { - RowLabel(icon: "info.circle", title: "Mulberry for iOS \(Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "")", - sub: "Coded by Claude (Anthropic) · MIT licence") + RowLabel(icon: "info.circle", title: "Mulberry for iOS \(AppVersion.version)", + sub: "Build \(AppVersion.build) · engine: \(Player.shared.engineName.isEmpty ? "—" : Player.shared.engineName) · Coded by Claude (Anthropic) · MIT licence") ButtonRow(icon: "desktopcomputer", title: "Mulberry for desktop", sub: "archlinux.tail7c4f5e.ts.net/git/astar76/Mulberry") { if let u = URL(string: "https://archlinux.tail7c4f5e.ts.net/git/astar76/Mulberry") { UIApplication.shared.open(u) } } diff --git a/App/UI/Visuals.swift b/App/UI/Visuals.swift index 9c3e0ef..c96d310 100644 --- a/App/UI/Visuals.swift +++ b/App/UI/Visuals.swift @@ -20,6 +20,7 @@ final class CookieModel { var target = [Float](repeating: 0, count: 48) var coverID: ObjectIdentifier? let clock = FrameClock() + private var lastLog = Date.distantPast func frame(_ now: Date, playing: Bool, bars: Bool, spectrum: Spectrum?) { let f = clock.step(now) @@ -36,6 +37,10 @@ final class CookieModel { } bass = b / 4 pulse += ((have ? 1.8 * max(0, bass - 0.45) : 0) - pulse) * min(1, 14 * f) + if now.timeIntervalSince(lastLog) > 2, playing { + lastLog = now + Log.i("visualizer: bars=\(bars) levels=\(have) max=\(String(format: "%.2f", lv.max() ?? 0)) bass=\(String(format: "%.2f", bass))") + } } var busy: Bool { spin > 0.01 || appear < 1 || pulse > 0.01 } diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..7dea76e --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.0.1 diff --git a/build.sh b/build.sh index e475a3c..89cc349 100755 --- a/build.sh +++ b/build.sh @@ -5,8 +5,8 @@ set -euo pipefail cd "$(dirname "$0")" -VERSION=${VERSION:-1.0.0} -BUILD=${BUILD:-$(date +%Y%m%d%H%M)} +VERSION=${VERSION:-$(cat VERSION)} +BUILD=${BUILD:-$(git rev-list --count HEAD 2>/dev/null || date +%Y%m%d%H%M)} SWIFT=${SWIFT:-$HOME/.local/opt/swift/usr/bin} SDK=${SDK:-$HOME/.local/opt/dl/sdk18/iPhoneOS18.6.sdk} TARGET=arm64-apple-ios17.0 @@ -60,7 +60,10 @@ $LD -dead_strip -o "$APP/Mulberry" "$OUT/obj/Mulberry.o" "$OUT/obj/compat.o" "${ echo "== widget extension" "$SWIFT/swiftc" "${common[@]}" -module-name MulberryWidgets -application-extension -c -wmo -num-threads 0 \ $(find Widget Shared -name '*.swift' -not -path 'Widget/Test/*' | sort) -o "$OUT/obj/MulberryWidgets.o" -$LD -dead_strip -application-extension -o "$APPEX/MulberryWidgets" "$OUT/obj/MulberryWidgets.o" "$OUT/obj/compat.o" +# Extensions must enter through Foundation's NSExtensionMain (Xcode links them with -e _NSExtensionMain); +# starting in our own main skips the XPC set-up and iOS sees the extension exit immediately. +$LD -dead_strip -application-extension -Xlinker -e -Xlinker _NSExtensionMain -framework Foundation \ + -o "$APPEX/MulberryWidgets" "$OUT/obj/MulberryWidgets.o" "$OUT/obj/compat.o" if [ "${TEST_WIDGET:-0}" = 1 ]; then echo "== test widget" @@ -68,7 +71,8 @@ if [ "${TEST_WIDGET:-0}" = 1 ]; then mkdir -p "$TAPPEX" "$SWIFT/swiftc" "${common[@]}" -module-name MulberryTestWidget -application-extension -parse-as-library -c -wmo -num-threads 0 \ Widget/Test/TestWidget.swift -o "$OUT/obj/MulberryTestWidget.o" - $LD -dead_strip -application-extension -o "$TAPPEX/MulberryTestWidget" "$OUT/obj/MulberryTestWidget.o" "$OUT/obj/compat.o" + $LD -dead_strip -application-extension -Xlinker -e -Xlinker _NSExtensionMain -framework Foundation \ + -o "$TAPPEX/MulberryTestWidget" "$OUT/obj/MulberryTestWidget.o" "$OUT/obj/compat.o" sed -e "s/@VERSION@/$VERSION/" -e "s/@BUILD@/$BUILD/" Resources/TestWidget-Info.plist > "$TAPPEX/Info.plist" fi diff --git a/docs/releases/1.0.1.md b/docs/releases/1.0.1.md new file mode 100644 index 0000000..32e067e --- /dev/null +++ b/docs/releases/1.0.1.md @@ -0,0 +1,12 @@ +# Mulberry for iOS 1.0.1 + +## Fixes +- Widgets: the widget extension now starts the way iOS expects (it quit right after launch, so no widgets were offered). +- Lists no longer end underneath the mini player and the navigation bar. +- The floating bass shape sits above the mini player instead of on top of it. +- Swipes on the cover in Now Playing: left/right = next/previous, down = close, up = lyrics. +- Universal engine: no more "player started when in a disconnected state" skipping. + +## New +- Playback engine setting: Standard (Apple's player), Universal (every format), Sound FX (Universal + EQ). +- Version and build number in Settings › About; a note appears after updating. diff --git a/tools/deploy b/tools/deploy new file mode 100755 index 0000000..870b87a --- /dev/null +++ b/tools/deploy @@ -0,0 +1,19 @@ +#!/bin/bash +# Copies the current build to the iPhone, removing older Mulberry packages there. +# Installs it too when passwordless sudo is allowed for TrollStore's helper; otherwise prints the command. +set -euo pipefail +cd "$(dirname "$0")/.." +IPHONE=${IPHONE:-mobile@192.168.1.94} +KEY=${IPHONE_KEY:-$HOME/.ssh/iphone_key} +V=$(cat VERSION) +IPA=build/Mulberry-$V-iOS.ipa +ssh_=(ssh -i "$KEY" -o BatchMode=yes -o ConnectTimeout=10 "$IPHONE") +"${ssh_[@]}" 'rm -f /var/mobile/mulberry-build/Mulberry-*.ipa /var/mobile/mulberry-build/Mulberry-*.deb' +scp -q -i "$KEY" "$IPA" "build/Mulberry-$V-iOS-rootless.deb" "$IPHONE:/var/mobile/mulberry-build/" +HELPER=/var/jb/Applications/TrollStoreLite.app/trollstorehelper +if "${ssh_[@]}" "sudo -n $HELPER install /var/mobile/mulberry-build/$(basename "$IPA")" 2>/dev/null; then + echo "installed Mulberry $V" +else + echo "copied Mulberry $V; install with:" + echo " sudo $HELPER install /var/mobile/mulberry-build/$(basename "$IPA")" +fi