From 533aeeeb51fa5e9d99a8f6a6ee8b23924c565fcc Mon Sep 17 00:00:00 2001 From: Vlad Frangu Date: Sat, 11 Nov 2023 21:39:40 +0200 Subject: [PATCH] chore: suggested changes --- Sources/VendettaTweak/Tweak.x.swift | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/Sources/VendettaTweak/Tweak.x.swift b/Sources/VendettaTweak/Tweak.x.swift index 144a5ef..ba54204 100644 --- a/Sources/VendettaTweak/Tweak.x.swift +++ b/Sources/VendettaTweak/Tweak.x.swift @@ -6,24 +6,25 @@ let vendettaLog = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "ven let source = URL(string: "vendetta")! let install_prefix = String(cString: get_install_prefix()) +let isJailbroken = FileManager.default.fileExists(atPath: "\(install_prefix)/Library/Application Support/VendettaTweak/VendettaPatches.bundle") -let vendettaPatchesBundlePath = - FileManager.default.fileExists( - atPath: "\(install_prefix)/Library/Application Support/VendettaTweak/VendettaPatches.bundle") - ? "\(install_prefix)/Library/Application Support/VendettaTweak/VendettaPatches.bundle" - : "\(Bundle.main.bundleURL.path)/VendettaPatches.bundle" +let vendettaPatchesBundlePath = if isJailbroken { + "\(install_prefix)/Library/Application Support/VendettaTweak/VendettaPatches.bundle" +} else { + "\(Bundle.main.bundleURL.path)/VendettaPatches.bundle" +} class FileManagerLoadHook: ClassHook { func containerURLForSecurityApplicationGroupIdentifier(_ groupIdentifier: NSString?) -> URL? { os_log("containerURLForSecurityApplicationGroupIdentifier called! %{public}@ groupIdentifier", log: vendettaLog, type: .debug, groupIdentifier ?? "nil") - if groupIdentifier != nil { - let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) - let lastPath = paths.last! - return lastPath.appendingPathComponent("AppGroup") + if (isJailbroken) { + return orig.containerURLForSecurityApplicationGroupIdentifier(groupIdentifier) } - return orig.containerURLForSecurityApplicationGroupIdentifier(groupIdentifier) + let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) + let lastPath = paths.last! + return lastPath.appendingPathComponent("AppGroup") } }