Liquid Glass and Apple Music touches for the Spotify iOS app. A GPL-3.0 fork of spoti.pw 0.21.1.
C
feat: Mod Settings warns about another tweak or an incompatible Spotify version
My-Name-Is-Jeffbf22f0f3a360
diff --git a/docs/tweaks.md b/docs/tweaks.mdindex e67b6a78..694a1d50 100644--- a/docs/tweaks.md+++ b/docs/tweaks.md@@ -384,7 +384,10 @@ App:on the first launch of a new version instead, What's new (WhatsNew.m), this version's section ofCHANGELOG.md, which scripts/whats-new.sh writes into a gitignored header at each make (a sectionthat came over from upstream is left out, so a build without its own has no sheet). The Mod- page offers both again. Laid out on the simulator by harness/onboarding/+ page offers both again. Environment.m says once per install state, a few seconds in, when+ EeveeSpotify is injected too (a dyld image named so) or Spotify is not the version the mod is+ made for (SGSpotifyMadeFor), and when a redesign below iOS 26 did not start; the first two stay+ as red rows at the top of Mod Settings. Laid out on the simulator by harness/onboarding/Every key a feature stores starts with `spotifyglass.`, whatever it holds: Reset all settings onthe Mod page removes by that prefix and has no list to keep up to date. It leaves `SGKeyStock` behind,diff --git a/harness/onboarding/README.md b/harness/onboarding/README.mdindex 6fe8e340..faa113ba 100644--- a/harness/onboarding/README.md+++ b/harness/onboarding/README.md@@ -7,9 +7,11 @@ the tweak's next make writes its own version's back../build.sh [version]xcrun simctl install <udid> build/OnboardingHarness.app- xcrun simctl launch <udid> com.vitrine.onboardingharness [tour | old | whatsnew] [pick]+ xcrun simctl launch <udid> com.vitrine.onboardingharness [tour | old | whatsnew | environment] [pick]`tour` is a first launch on iOS 26 and up: the logo lands, then the page comes in with Redesigned picked.`old` fakes an OS below 26: Legacy picked, the redesign card untested. `pick` taps the other card threeseconds in, which shows the note under the cards: what Legacy goes without, or below 26 what the redesign-risks. `whatsnew` puts the sheet up instead.+risks. `whatsnew` puts the sheet up instead. `environment` loads a stand-in `EeveeSpotify.dylib` from the+app and runs the install check, which finds it and the harness's own version (1.0, not Spotify's) and says+both in one alert about five seconds in.diff --git a/harness/onboarding/build.sh b/harness/onboarding/build.shindex a4f5a6ee..dcc728be 100755--- a/harness/onboarding/build.sh+++ b/harness/onboarding/build.sh@@ -14,13 +14,18 @@ ALLOW_UPSTREAM=1 ../../scripts/whats-new.sh "$VERSION" ../../CHANGELOG.md "$SRC/SDK=$(xcrun --sdk iphonesimulator --show-sdk-path)xcrun -sdk iphonesimulator clang -target arm64-apple-ios17.0-simulator -fobjc-arc -g -O0 \-I"$SRC" -isysroot "$SDK" -Wno-deprecated-declarations -DSG_VERSION="\"$VERSION\"" \- main.m "$SRC"/App/Onboarding/Tour.m "$SRC"/App/Onboarding/WhatsNew.m "$SRC"/App/About/Update.m \+ main.m "$SRC"/App/Onboarding/Tour.m "$SRC"/App/Onboarding/WhatsNew.m "$SRC"/App/Onboarding/Environment.m \+ "$SRC"/App/About/Update.m \"$SRC"/Settings/SGPage.m "$SRC"/Settings/SGPageStyle.m \"$SRC"/Core/SGLog.m "$SRC"/Core/SGPrefs.m "$SRC"/Core/SGViewTree.m "$SRC"/Core/SGGlass.m \"$SRC"/Core/SGBackdrop.m "$SRC"/Core/SGFlagForce.m \-framework UIKit -framework QuartzCore -framework CoreGraphics -framework CoreImage -framework Foundation \-o "$OUT/OnboardingHarness.app/OnboardingHarness"+# A stand-in for EeveeSpotify's dylib, which the install check finds by its name alone.+echo 'void sg_stand_in(void) {}' | xcrun -sdk iphonesimulator clang -target arm64-apple-ios17.0-simulator -isysroot "$SDK" \+ -x c - -dynamiclib -o "$OUT/OnboardingHarness.app/EeveeSpotify.dylib"+cat > "$OUT/OnboardingHarness.app/Info.plist" <<'PLIST'<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">diff --git a/harness/onboarding/main.m b/harness/onboarding/main.mindex f17d9722..8bef4a43 100644--- a/harness/onboarding/main.m+++ b/harness/onboarding/main.m@@ -4,8 +4,11 @@// tour the tour, as on a first launch (the default)// old the tour as below iOS 26: the redesign card untested, Legacy picked// whatsnew the What's new sheet-// pick taps the other look's card two seconds in, to see the note change+// pick taps the other look's card three seconds in, to see the note change+// environment loads a stand-in EeveeSpotify.dylib and runs the install check (the harness's own+// version, 1.0, is not Spotify's either), whose alert follows about 5 s in#import <UIKit/UIKit.h>+#import <dlfcn.h>#import "App/Onboarding/Onboarding.h"#import "Core/SGPrefs.h"@@ -24,6 +27,8 @@ NSString *SGRedesignUntestedWarning(void) {return [NSString stringWithFormat:@"The redesign is built on iOS 26's Liquid Glass. iOS %@ draws a blur in its place, and nobody has tested the redesign there: pages can be laid out wrongly, and Spotify can freeze as it starts. If Spotify does not start with it, the next launch goes back to Legacy.", @"17.5"];}void SGShowSigningFixIfPending(void) {}+// Settings/SGModPage.m, for the Mod Settings rows, which the harness does not show.+SGModRow *SGWarningRow(NSString *title, NSString *subtitle, void (^action)(void)) { return nil; }@interface Delegate : UIResponder <UIApplicationDelegate>@end@@ -53,6 +58,15 @@ void SGShowSigningFixIfPending(void) {}self.window.rootViewController = home;[self.window makeKeyAndVisible];+ if ([arguments containsObject:@"environment"]) {+ [NSUserDefaults.standardUserDefaults removeObjectForKey:@"spotifyglass.environment.told"];+ NSString *eevee = [NSBundle.mainBundle pathForResource:@"EeveeSpotify" ofType:@"dylib"];+ NSLog(@"harness: EeveeSpotify.dylib %@", dlopen(eevee.UTF8String, RTLD_NOW) ? @"loaded" : @"not loaded");+ NSLog(@"harness: injected %d, Spotify %@", SGEeveeSpotifyInjected(), SGSpotifyVersion());+ SGCheckEnvironmentOnce();+ [NSUserDefaults.standardUserDefaults setBool:YES forKey:SGKeyOnboardingSeen];+ return;+ }BOOL whatsNew = [arguments containsObject:@"whatsnew"];dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.8 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{NSLog(@"harness: %lu changes in the notes", (unsigned long)SGWhatsNewChanges().count);diff --git a/harness/player/build.sh b/harness/player/build.shindex 830bb2b8..0ad0628c 100755--- a/harness/player/build.sh+++ b/harness/player/build.sh@@ -24,7 +24,7 @@ xcrun -sdk iphonesimulator clang -target arm64-apple-ios17.0-simulator -fobjc-ar"$SRC"/Redesigned/Kit/SGRedesign.m \"$SRC"/Redesigned/Player/PlayerSettings.m "$SRC"/Redesigned/NowPlayingBar/NowPlayingBarSettings.m \"$SRC"/Settings/SGPage.m "$SRC"/Settings/SGPageStyle.m "$SRC"/Settings/SGModPage.m "$SRC"/Settings/SGGlowSwitch.m \- "$SRC"/Redesigned/Lyrics/SGRKaraokeView.m "$SRC"/Redesigned/Lyrics/SGRSingButton.m "$SRC"/Redesigned/Lyrics/MeaningSheet.m "$SRC"/Redesigned/Lyrics/LyricsText.m "$SRC"/Shared/Lyrics/KaraokeTiming.m "$SRC"/Shared/AdBlock/Protobuf.m \+ "$SRC"/Redesigned/Lyrics/SGRKaraokeView.m "$SRC"/Redesigned/Lyrics/LyricsLook.m "$SRC"/Redesigned/Lyrics/SGRSingButton.m "$SRC"/Redesigned/Lyrics/MeaningSheet.m "$SRC"/Redesigned/Lyrics/LyricsText.m "$SRC"/Shared/Lyrics/KaraokeTiming.m "$SRC"/Shared/AdBlock/Protobuf.m \-framework UIKit -framework QuartzCore -framework CoreGraphics -framework CoreImage -framework Foundation -framework Symbols -framework AVFoundation -framework CoreMedia \-o "$OUT/PlayerHarness.app/PlayerHarness"diff --git a/tweak/Sources/App/About/AboutSettings.m b/tweak/Sources/App/About/AboutSettings.mindex ecaf7dc8..a525f178 100644--- a/tweak/Sources/App/About/AboutSettings.m+++ b/tweak/Sources/App/About/AboutSettings.m@@ -37,7 +37,8 @@ static SGModRow *withSymbol(SGModRow *row, NSString *symbol) {UIViewController *SGAboutPage(void) {SGModRow *reset = withSymbol(SGActionRow(@"Reset all settings", nil, ^{ confirmReset(); }), @"trash");reset.color = SGRed();- NSString *spotify = [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"] ?: @"unknown";+ NSString *spotify = SGSpotifyVersion();+ if (![spotify isEqualToString:SGSpotifyMadeFor]) spotify = [NSString stringWithFormat:@"%@, made for %@", spotify, SGSpotifyMadeFor];// The row reads out where the build stands and opens the changelog of everything newer than it.SGModRow *updates = SGPageRow(@"Updates", ^UIViewController *{ return SGUpdatePage(); });updates.value = ^NSString *{ return SGUpdateStatus(); };diff --git a/tweak/Sources/App/ModSettings.x b/tweak/Sources/App/ModSettings.xindex 3969314b..b7250471 100644--- a/tweak/Sources/App/ModSettings.x+++ b/tweak/Sources/App/ModSettings.x@@ -24,6 +24,7 @@#import "Shared/ListeningStats/ListeningStats.h"#import "Shared/Sing/Sing.h"#import "App/About/About.h"+#import "App/Onboarding/Onboarding.h"#import "Redesigned/Album/Album.h"#import "Pages.h"@@ -42,7 +43,9 @@ static UIViewController *modSettingsPage(void) {// A build the lock screen cannot open leads the page, above the tweaks: it is the one thing here// that no switch can put right, and it is worth reading before anything else.SGModRow *signing = SGSigningWarningRow();- if (signing) [sections addObject:SGSection(nil, @[signing])];+ NSMutableArray<SGModRow *> *warnings = [NSMutableArray arrayWithArray:SGEnvironmentWarningRows()];+ if (signing) [warnings insertObject:signing atIndex:0];+ if (warnings.count) [sections addObject:SGSection(nil, warnings)];// Appearance opens a page of its own, on a card of its own, so the parts below stay one tap from the top.[sections addObject:SGSection(nil, @[pageRow(@"Appearance", @"paintpalette", UIColor.systemBlueColor, ^UIViewController *{ return SGAppearancePage(); })])];SGModRow *mod = pageRow(@"Mod", @"info.circle", UIColor.systemGrayColor, ^UIViewController *{ return SGAboutPage(); });diff --git a/tweak/Sources/App/Onboarding/Environment.m b/tweak/Sources/App/Onboarding/Environment.mnew file mode 100644index 00000000..3cde83dc--- /dev/null+++ b/tweak/Sources/App/Onboarding/Environment.m@@ -0,0 +1,122 @@+// What about the install itself can work against the mod, said once and kept at the top of Mod Settings+// while it lasts: EeveeSpotify injected beside it, a Spotify other than the one it is made for, and a+// redesign below iOS 26 that did not start (Core/SGUIMode.h), which turned itself off.+#import "Shared/Lyrics/Lyrics.h"+#import "Core/SGCore.h"+#import "Settings/SGModPage.h"+#import "Settings/SGPageStyle.h"+#import "Onboarding.h"++static NSString *const kTold = @"spotifyglass.environment.told";+static const NSTimeInterval kSettle = 4; // after the first activation, behind the signing sheet's 3 s+static const NSTimeInterval kRetry = 4;+static const NSInteger kTries = 45; // three minutes of waiting for the screen, then the rows say it++// A problem is its title and what it means, @[title, body].+typedef NSArray<NSString *> *SGProblem;++NSString *SGSpotifyVersion(void) {+ return [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"] ?: @"unknown";+}++// A Spotify whose version can be read and is not the one the mod is made for; one that cannot be read+// says nothing, rather than "Spotify unknown".+static BOOL otherVersion(void) {+ NSString *version = [NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"];+ return [version isKindOfClass:NSString.class] && ![version isEqualToString:SGSpotifyMadeFor];+}++static SGProblem eevee(void) {+ return @[@"EeveeSpotify is injected too",+ @"Vitrine already blocks ads and brings lyrics, and EeveeSpotify hooks the same parts of Spotify. With both, Spotify can freeze as it starts or show the wrong lyrics. Sign Spotify again without EeveeSpotify."];+}++static SGProblem version(void) {+ return @[[NSString stringWithFormat:@"Spotify %@ is not the version Vitrine is made for", SGSpotifyVersion()],+ [NSString stringWithFormat:@"Vitrine is made for Spotify %@. On another version some of its changes find nothing to change, and some screens can look wrong or crash. Inject Vitrine into Spotify %@.",+ SGSpotifyMadeFor, SGSpotifyMadeFor]];+}++static SGProblem fellBack(void) {+ return @[@"The redesign did not start",+ [NSString stringWithFormat:@"Spotify did not get going with the redesign on iOS %@, so it is back in Legacy and Redesigned UI is off. Appearance can turn it on again.",+ UIDevice.currentDevice.systemVersion]];+}++// One problem is the alert's title and message; several are a paragraph each under a count.+static void tell(NSArray<SGProblem> *list) {+ NSString *title = list.count == 1 ? list[0][0] : [NSString stringWithFormat:@"%lu things to know", (unsigned long)list.count];+ NSMutableArray<NSString *> *paragraphs = [NSMutableArray array];+ for (SGProblem problem in list) {+ [paragraphs addObject:list.count == 1 ? problem[1] : [NSString stringWithFormat:@"%@.\n%@", problem[0], problem[1]]];+ }+ UIAlertController *alert = [UIAlertController alertControllerWithTitle:title+ message:[paragraphs componentsJoinedByString:@"\n\n"]+ preferredStyle:UIAlertControllerStyleAlert];+ [alert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:nil]];+ [SGTopController() presentViewController:alert animated:YES completion:nil];+}++// What about the install is worth saying.+static NSArray<SGProblem> *installProblems(void) {+ NSMutableArray<SGProblem> *list = [NSMutableArray array];+ if (SGEeveeSpotifyInjected()) [list addObject:eevee()];+ if (otherVersion()) [list addObject:version()];+ return list;+}++// The rows stay while the install is so; the fall back is said once and is over.+NSArray<SGModRow *> *SGEnvironmentWarningRows(void) {+ NSMutableArray<SGModRow *> *rows = [NSMutableArray array];+ if (SGEeveeSpotifyInjected())+ [rows addObject:SGWarningRow(@"EeveeSpotify is injected too", @"Tap for what that does", ^{ tell(@[eevee()]); })];+ if (otherVersion())+ [rows addObject:SGWarningRow([NSString stringWithFormat:@"Made for Spotify %@", SGSpotifyMadeFor],+ [NSString stringWithFormat:@"This is %@. Tap for what that does", SGSpotifyVersion()],+ ^{ tell(@[version()]); })];+ return rows;+}++// Once per install state: the same EeveeSpotify and the same Spotify version say nothing again, a+// change says what it is now.+static NSString *state(void) {+ return [NSString stringWithFormat:@"eevee %d, spotify %@", SGEeveeSpotifyInjected(), SGSpotifyVersion()];+}++static void tellWhenClear(NSInteger tries) {+ UIViewController *top = SGTopController();+ // The tour, What's new and the signing sheet own the screen first; an alert presented from one of+ // them lands nowhere, so this one waits its turn. It also waits for the app to be in front, so it is+ // not shown, and counted as told, to someone who sent Spotify away in its first seconds.+ BOOL front = UIApplication.sharedApplication.applicationState == UIApplicationStateActive;+ if (!front || !top || SGOnboardingShowing() || [top isKindOfClass:UIAlertController.class]) {+ if (tries <= 0) return;+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(kRetry * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{+ tellWhenClear(tries - 1);+ });+ return;+ }+ // The fall back is news every time; the install's state only when it changed.+ NSUserDefaults *store = NSUserDefaults.standardUserDefaults;+ NSMutableArray<SGProblem> *list = [NSMutableArray array];+ if (SGRedesignFellBack()) [list addObject:fellBack()];+ if (![[store stringForKey:kTold] isEqualToString:state()]) {+ [store setObject:state() forKey:kTold];+ [list addObjectsFromArray:installProblems()];+ }+ if (list.count) tell(list);+}++void SGCheckEnvironmentOnce(void) {+ __block id token = [NSNotificationCenter.defaultCenter addObserverForName:UIApplicationDidBecomeActiveNotification+ object:nil+ queue:nil+ usingBlock:^(NSNotification *note) {+ [NSNotificationCenter.defaultCenter removeObserver:token];+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(kSettle * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{+ if (SGEeveeSpotifyInjected()) SGLog(@"environment: EeveeSpotify is injected too");+ if (otherVersion()) SGLog(@"environment: Spotify %@, made for %@", SGSpotifyVersion(), SGSpotifyMadeFor);+ tellWhenClear(kTries);+ });+ }];+}diff --git a/tweak/Sources/App/Onboarding/Onboarding.h b/tweak/Sources/App/Onboarding/Onboarding.hindex 949777da..7d7cbbb0 100644--- a/tweak/Sources/App/Onboarding/Onboarding.h+++ b/tweak/Sources/App/Onboarding/Onboarding.h@@ -21,5 +21,15 @@ NSArray<SGUpdateChange *> *SGWhatsNewChanges(void);void SGShowWhatsNew(void);BOOL SGWhatsNewShowing(void);+// Environment.m: what about the install can work against the mod. Said once per install state, a few+// seconds after Spotify comes up and behind the tour, What's new and the signing sheet, and kept as+// warning rows at the top of Mod Settings while it lasts.+#define SGSpotifyMadeFor @"9.1.78" // the Spotify this build is made for, and its flag table read from+@class SGModRow;+// SGEeveeSpotifyInjected() is Shared/Lyrics/Lyrics.h's.+NSString *SGSpotifyVersion(void);+NSArray<SGModRow *> *SGEnvironmentWarningRows(void);+void SGCheckEnvironmentOnce(void);+// The tour's prominent glass button, also What's new's Continue.UIButton *SGOnboardingButton(NSString *title);diff --git a/tweak/Sources/App/Onboarding/Onboarding.x b/tweak/Sources/App/Onboarding/Onboarding.xindex 33e95ddb..b4ec78be 100644--- a/tweak/Sources/App/Onboarding/Onboarding.x+++ b/tweak/Sources/App/Onboarding/Onboarding.x@@ -25,6 +25,7 @@ static BOOL newVersion(void) {%end%ctor {+ SGCheckEnvironmentOnce();if (SGFlag(SGKeyOnboardingSeen, NO) && !newVersion()) return;%init;SGRequireClasses(@[@"_TtC19Home_FunkisPageImpl20FunkisViewController"]);