From 053232ed26e9ffdb8c3af7501ca407e1add532bc Mon Sep 17 00:00:00 2001 From: joywayer Date: Tue, 23 Jun 2026 17:24:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E6=8E=88=E6=9D=83=E9=93=BE?= =?UTF-8?q?=E8=B7=AF=E8=AF=8A=E6=96=AD=20print=20=E6=B8=85=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 授权链路已跑通(commit 625f504),撤掉 a060f29 加的临时诊断 print + 本次 shim 的 install 成功日志。AccreditLoginHandler / WeChatManager / WXOpenURLShim 三处共 13 行 print 一次性清干净,行为不变。 Co-Authored-By: Claude Opus 4.7 --- .../Source/Bridge/Handlers/AccreditLoginHandler.swift | 4 ---- ylgamehall/Source/SDK/WeChat/WXOpenURLShim.swift | 6 +----- ylgamehall/Source/SDK/WeChat/WeChatManager.swift | 8 -------- 3 files changed, 1 insertion(+), 17 deletions(-) diff --git a/ylgamehall/Source/Bridge/Handlers/AccreditLoginHandler.swift b/ylgamehall/Source/Bridge/Handlers/AccreditLoginHandler.swift index 3b62d55..41494b6 100644 --- a/ylgamehall/Source/Bridge/Handlers/AccreditLoginHandler.swift +++ b/ylgamehall/Source/Bridge/Handlers/AccreditLoginHandler.swift @@ -21,14 +21,12 @@ public enum AccreditLoginHandler { public static func register(on bridge: any BridgeProtocol) { bridge.register("accreditlogin") { _, callback in - print("[Bridge] accreditlogin H5 调用命中 ✅") callback?(.string("Response from accreditlogin")) // 拉起微信授权 → 拿 7 字段 → 反向 callback sharelogin Task { @MainActor in do { let user = try await WeChatAuth.authorize() - print("[Bridge] accreditlogin 拿到 user,发 sharelogin 反向 callback") bridge.call("sharelogin", data: .object([ // 字段名严格 1:1 contract §3.2 表 [10] / msext NewRootVC.m:2428 "openid": .string(user.openid), @@ -40,10 +38,8 @@ public enum AccreditLoginHandler { "unionid": .string(user.unionid) ]), callback: nil) } catch WeChatAuthError.userCancelled { - print("[Bridge] accreditlogin 用户取消授权(errCode -2)") // msext 行为:用户取消不弹 alert、不触发 sharelogin } catch { - print("[Bridge] accreditlogin 失败:\(error)") // 其它失败也吞下(msext 同款乐观策略:不反向通知 H5) } } diff --git a/ylgamehall/Source/SDK/WeChat/WXOpenURLShim.swift b/ylgamehall/Source/SDK/WeChat/WXOpenURLShim.swift index f25976e..10f2417 100644 --- a/ylgamehall/Source/SDK/WeChat/WXOpenURLShim.swift +++ b/ylgamehall/Source/SDK/WeChat/WXOpenURLShim.swift @@ -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:)") } } diff --git a/ylgamehall/Source/SDK/WeChat/WeChatManager.swift b/ylgamehall/Source/SDK/WeChat/WeChatManager.swift index 25133df..a58a028 100644 --- a/ylgamehall/Source/SDK/WeChat/WeChatManager.swift +++ b/ylgamehall/Source/SDK/WeChat/WeChatManager.swift @@ -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))