WeChat OpenSDK 1.8.2 内部仍调 -[UIApplication openURL:],本项目链接 iOS 26 SDK 时被系统强制返回 NO("BUG IN CLIENT OF UIKIT ... Force returning false"),导致 WXApi.sendAuthReq / sendReq 一律失败、H5 拿到 authStepFailed(-3)。 WXOpenURLShim 用 method_setImplementation 把这一个 selector 的 IMP 替换为转发到 open(_:options:completionHandler:) 并同步返回 true, 作用域仅限此老 API。在 WXApi.registerApp 之前 install 一次。 daoqi/msext 用 1.8.2 没此问题,是因为它 IPA 链接的 base SDK 更低、 系统对老 app 放行 openURL:。新外壳无此豁免,需要这层兜底。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
35 lines
1.2 KiB
Swift
35 lines
1.2 KiB
Swift
//
|
||
// AppDelegate.swift
|
||
// ylgamehall
|
||
//
|
||
|
||
import UIKit
|
||
|
||
@main
|
||
final class AppDelegate: UIResponder, UIApplicationDelegate {
|
||
|
||
func application(_ application: UIApplication,
|
||
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||
application.applicationSupportsShakeToEdit = true
|
||
|
||
// 微信 SDK 1.8.2 内部仍调已弃用的 -[UIApplication openURL:],iOS 17+ SDK
|
||
// 链接的 app 会被系统强制返回 NO。必须在 WXApi.registerApp 之前 swizzle。
|
||
WXOpenURLShim.install()
|
||
|
||
// Phase 4.E 微信 SDK 启动注册(canImport 守卫:未链接时 no-op)
|
||
WeChatSDK.register()
|
||
|
||
// Phase 5 高德定位 SDK 启动注册(iOS 14+ 隐私合规 3 步,canImport 守卫:未链接时 no-op)
|
||
AMapWrapper.bootstrap()
|
||
|
||
return true
|
||
}
|
||
|
||
func application(_ application: UIApplication,
|
||
configurationForConnecting connectingSceneSession: UISceneSession,
|
||
options: UIScene.ConnectionOptions) -> UISceneConfiguration {
|
||
UISceneConfiguration(name: "Default Configuration",
|
||
sessionRole: connectingSceneSession.role)
|
||
}
|
||
}
|