微信授权链路诊断 print 清理

授权链路已跑通(commit 625f504),撤掉 a060f29 加的临时诊断 print
+ 本次 shim 的 install 成功日志。AccreditLoginHandler / WeChatManager /
WXOpenURLShim 三处共 13 行 print 一次性清干净,行为不变。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
joywayer
2026-06-23 17:24:59 +08:00
co-authored by Claude Opus 4.7
parent 625f504b85
commit 053232ed26
3 changed files with 1 additions and 17 deletions
@@ -33,10 +33,7 @@ public enum WXOpenURLShim {
installed = true
let sel = NSSelectorFromString("openURL:")
guard let method = class_getInstanceMethod(UIApplication.self, sel) else {
print("[WXOpenURLShim] ⚠️ openURL: method not found, skip")
return
}
guard let method = class_getInstanceMethod(UIApplication.self, sel) else { return }
let block: @convention(block) (UIApplication, URL) -> Bool = { app, url in
app.open(url, options: [:], completionHandler: nil)
@@ -44,6 +41,5 @@ public enum WXOpenURLShim {
}
let imp = imp_implementationWithBlock(block as Any)
method_setImplementation(method, imp)
print("[WXOpenURLShim] ✅ swizzled -[UIApplication openURL:] → open(_:options:completionHandler:)")
}
}
@@ -39,11 +39,6 @@ public final class WeChatManager: NSObject {
/// openURL SDK delegate
/// 1.x `WXApi.send(req)` deprecated vc/delegate H5
public func authorize() async throws -> WXAuthCodePayload {
print("[WeChat] authorize() 开始")
print("[WeChat] - WXApi.isWXAppInstalled = \(WXApi.isWXAppInstalled())")
// ObjC selector +getApiVersion Swift getVersion()
// Swift 3+ ObjC name +[WXApi getApiVersion]
print("[WeChat] - WXApi.getVersion = \(WXApi.getVersion() ?? "nil")")
let state = UUID().uuidString
return try await withCheckedThrowingContinuation { cont in
authPending[state] = cont
@@ -52,15 +47,12 @@ public final class WeChatManager: NSObject {
req.state = state
guard let vc = Self.topmostViewController() else {
print("[WeChat] ⚠️ topmostViewController() 返回 nil,无 present 上下文")
authPending.removeValue(forKey: state)
cont.resume(throwing: WeChatError.authFailed(-3))
return
}
print("[WeChat] 调 sendAuthReq vc=\(type(of: vc)) scope=\(Self.authScope) state=\(state)")
// 1.x sendAuthReq BOOL completion
let success = WXApi.sendAuthReq(req, viewController: vc, delegate: self)
print("[WeChat] sendAuthReq 返回 success=\(success)")
if !success {
if let pending = authPending.removeValue(forKey: state) {
pending.resume(throwing: WeChatError.authFailed(-3))