From 723e982bf308b4315c5e319f8ffe341ace08036f Mon Sep 17 00:00:00 2001 From: Sunny Young Date: Fri, 5 Dec 2025 17:37:06 +0800 Subject: [PATCH] fix a config.json reading issue --- Sources/WeChatTweak/main.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Sources/WeChatTweak/main.swift b/Sources/WeChatTweak/main.swift index e5fa5c1..a9be6d6 100644 --- a/Sources/WeChatTweak/main.swift +++ b/Sources/WeChatTweak/main.swift @@ -50,7 +50,15 @@ struct Patch: ParsableCommand { return URL(fileURLWithPath: $0) } ) - var config: URL = URL(fileURLWithPath: "config.json") + var config: URL = { + var size: UInt32 = 0 + _NSGetExecutablePath(nil, &size) + var buffer = [CChar](repeating: 0, count: Int(size)) + guard _NSGetExecutablePath(&buffer, &size) == 0, let path = String(utf8String: buffer) else { + return URL(fileURLWithPath: FileManager.default.currentDirectoryPath) + } + return URL(fileURLWithPath: path).resolvingSymlinksInPath().deletingLastPathComponent().appendingPathComponent("config.json") + }() func run() throws { let configs = try JSONDecoder().decode([Config].self, from: Data(contentsOf: self.config))