potential fix for lyrics crashes

This commit is contained in:
eevee
2025-04-06 13:44:34 +03:00
parent f157d3e56f
commit d00eaeee5b
2 changed files with 17 additions and 5 deletions

View File

@@ -14,6 +14,19 @@ struct WindowHelper {
func present(_ viewController: UIViewController) {
rootViewController.present(viewController, animated: true)
}
func findFirstSubview(_ regex: String, in view: UIView) -> UIView? {
for subview in view.subviews {
if NSStringFromClass(type(of: subview)) ~= regex {
return subview
}
if let found = findFirstSubview(regex, in: subview) {
return found
}
}
return nil
}
func findFirstViewController(_ regex: String) -> UIViewController? {
let rootView = self.rootViewController.view!

View File

@@ -63,12 +63,11 @@ class LyricsOnlyViewControllerHook: ClassHook<UIViewController> {
}
//
let lyricsLabel = EeveeSpotify.isOldSpotifyVersion
? lyricsHeaderViewController.view.subviews.first?.subviews.first
: lyricsHeaderViewController.view.subviews.first
guard let lyricsLabel = lyricsLabel else {
guard let lyricsLabel = WindowHelper.shared.findFirstSubview(
"SPTEncoreLabel",
in: lyricsHeaderViewController.view
) else {
return
}