修复 SDK 真实接入后的 Swift 编译错误 + Xcode 链接配置

实测三个 SDK(微信 / 高德 / 七牛)链接进 Target 后,暴露出 9 个 Swift 编译错误,逐一修正:

代码侧(5 个 Swift 文件):
- AMapWrapper:updatePrivacyShow / updatePrivacyAgree 是 AMapLocationManager
  类方法(since 2.8.0),不在 AMapServices 上;改为 AMapLocationManager.*
  并补 import AMapLocationKit
- BackGameDataHandler:删 `WXApi.delegate = nil`。新版 SDK 2.x 无 static
  delegate API,delegate 由调用方逐次传给 handleOpenURL/sendAuthReq 并被
  SDK 弱引用;WeChatManager singleton 长生命周期不析构,无需 cleanup
- QiniuConfig / QiniuTokenSigner:所有 static 成员标 nonisolated,让 actor
  QiniuUploader 可直接调,无需 await MainActor.run
- QiniuUploader:QNUploadManager() 在七牛 SDK 8.x 已 kQNDeprecated,改用
  initWithConfiguration: + defaultConfigurationV2

工程侧(pbxproj,Xcode UI 自动写入):
- 新 Frameworks group 容纳 Vendor/WechatSDK / Vendor/AMap 引用
- WechatOpenSDK-NoPay.xcframework:Embed & Sign(动态库)
- AMapFoundationKit / AMapLocationKit:Do Not Embed(静态 fat .framework)

BuildProject 验证:Swift 全部编译通过;剩余 AMap fat framework arch 冲突
(M Mac iOS-simulator)是工程配置选择,下个 commit 处理。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
joywayer
2026-06-23 01:03:29 +08:00
co-authored by Claude Opus 4.7
parent 52ad421d22
commit a3679aba7d
6 changed files with 79 additions and 26 deletions
+44
View File
@@ -9,9 +9,30 @@
/* Begin PBXBuildFile section */
1A2954622FE840DA009E703E /* ZIPFoundation in Frameworks */ = {isa = PBXBuildFile; productRef = 1A2954612FE840DA009E703E /* ZIPFoundation */; };
1A2954DA2FE97D61009E703E /* Qiniu in Frameworks */ = {isa = PBXBuildFile; productRef = 1A2954D92FE97D61009E703E /* Qiniu */; };
1A2954DF2FE99C2C009E703E /* WechatOpenSDK-NoPay.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A2954DE2FE99C2C009E703E /* WechatOpenSDK-NoPay.xcframework */; };
1A2954E02FE99C2C009E703E /* WechatOpenSDK-NoPay.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 1A2954DE2FE99C2C009E703E /* WechatOpenSDK-NoPay.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
1A2954E32FE99C53009E703E /* AMapFoundationKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A2954E22FE99C53009E703E /* AMapFoundationKit.framework */; };
1A2954E62FE99C63009E703E /* AMapLocationKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A2954E52FE99C63009E703E /* AMapLocationKit.framework */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
1A2954E12FE99C2C009E703E /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
1A2954E02FE99C2C009E703E /* WechatOpenSDK-NoPay.xcframework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
1A2954DE2FE99C2C009E703E /* WechatOpenSDK-NoPay.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = "WechatOpenSDK-NoPay.xcframework"; path = "Vendor/WechatSDK/WechatOpenSDK-NoPay.xcframework"; sourceTree = "<group>"; };
1A2954E22FE99C53009E703E /* AMapFoundationKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AMapFoundationKit.framework; path = Vendor/AMap/AMapFoundationKit.framework; sourceTree = "<group>"; };
1A2954E52FE99C63009E703E /* AMapLocationKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AMapLocationKit.framework; path = Vendor/AMap/AMapLocationKit.framework; sourceTree = "<group>"; };
1A714BD22FE8047A00913338 /* ylgamehall.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ylgamehall.app; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
@@ -42,17 +63,31 @@
buildActionMask = 2147483647;
files = (
1A2954622FE840DA009E703E /* ZIPFoundation in Frameworks */,
1A2954E62FE99C63009E703E /* AMapLocationKit.framework in Frameworks */,
1A2954E32FE99C53009E703E /* AMapFoundationKit.framework in Frameworks */,
1A2954DA2FE97D61009E703E /* Qiniu in Frameworks */,
1A2954DF2FE99C2C009E703E /* WechatOpenSDK-NoPay.xcframework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
1A2954DB2FE99B2F009E703E /* Frameworks */ = {
isa = PBXGroup;
children = (
1A2954E52FE99C63009E703E /* AMapLocationKit.framework */,
1A2954E22FE99C53009E703E /* AMapFoundationKit.framework */,
1A2954DE2FE99C2C009E703E /* WechatOpenSDK-NoPay.xcframework */,
);
name = Frameworks;
sourceTree = "<group>";
};
1A714BC92FE8047A00913338 = {
isa = PBXGroup;
children = (
1A714BD42FE8047A00913338 /* ylgamehall */,
1A2954DB2FE99B2F009E703E /* Frameworks */,
1A714BD32FE8047A00913338 /* Products */,
);
sourceTree = "<group>";
@@ -75,6 +110,7 @@
1A714BCE2FE8047A00913338 /* Sources */,
1A714BCF2FE8047A00913338 /* Frameworks */,
1A714BD02FE8047A00913338 /* Resources */,
1A2954E12FE99C2C009E703E /* Embed Frameworks */,
);
buildRules = (
);
@@ -159,6 +195,10 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = NX5W3B4QP3;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Vendor/AMap",
);
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ylgamehall/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
@@ -192,6 +232,10 @@
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = NX5W3B4QP3;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Vendor/AMap",
);
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = ylgamehall/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
@@ -19,7 +19,8 @@
//
// SDK SDK
//
// Phase 4.E `WXApi.delegate = nil`canImport Xcode Embed
// Phase 4.E SDK2.x static delegate API handleOpenURL/sendAuthReq
// SDK WeChatManager singleton pop
// Phase 5 `LocationService.shared.stop()`canImport
// Xcode Embed AMapLocationKit
// Phase 3.B/C/D / `AudioRecorder.shared.cancel()` opencore-amr
@@ -31,10 +32,6 @@
import Foundation
#if canImport(WechatOpenSDK)
import WechatOpenSDK
#endif
public enum BackGameDataHandler {
public static func register(on bridge: any BridgeProtocol) {
@@ -52,10 +49,10 @@ public enum BackGameDataHandler {
// msext gameController.m:691-709 + cleanUpAction
AudioPlayer.shared.stopAllBackground()
#if canImport(WechatOpenSDK)
// msext gameController.m:699 WXApi delegate VC
WXApi.delegate = nil
#endif
// SDK 2.xdelegate handleOpenURL: / sendAuthReq:...:delegate:
// SDK static delegate WeChatManager
// shared singleton pop
// msext gameController.m:699 [WXApi setDelegate:nil] 1.x SDK API
#if canImport(AMapLocationKit)
// msext gameController.m:2473-2478 cleanUpAction
+8 -6
View File
@@ -10,26 +10,28 @@
import Foundation
/// nonisolated使 QiniuUploaderactor MainActor
/// immutable static await MainActor.run
public enum QiniuConfig {
/// AccessKey沿 msext QiniuConfig.m:12
public static let accessKey = "dQbQLUm1jIuL9PEq4jd6VKB-6pPxPEdg7le9KeBm"
public nonisolated static let accessKey = "dQbQLUm1jIuL9PEq4jd6VKB-6pPxPEdg7le9KeBm"
/// SecretKey沿 msext QiniuConfig.m:13 HMAC-SHA1 putPolicy
public static let secretKey = "RCZpwLhAPoQ2sQQyWXzMJc7Po2MyZWfUJeW4Jmfq"
public nonisolated static let secretKey = "RCZpwLhAPoQ2sQQyWXzMJc7Po2MyZWfUJeW4Jmfq"
/// 沿 msext QiniuConfig.m:16 putPolicy scope
public static let bucketName = "iosaudio"
public nonisolated static let bucketName = "iosaudio"
/// CDN 沿 msext qiniudomain/
/// msext fallback `iosaudio.daoqi8888.cn` `daoqi88`
/// 沿
public static let cdnDomain = "iosaudio.daoqi88.cn"
public nonisolated static let cdnDomain = "iosaudio.daoqi88.cn"
/// key msext QiniuConfig.m:22
public static let recordingDirectory = ""
public nonisolated static let recordingDirectory = ""
/// 访 URL`http://{cdnDomain}/{key}`msext QiniuManager.m:197
public static func publicURL(forKey key: String) -> String {
public nonisolated static func publicURL(forKey key: String) -> String {
"http://\(cdnDomain)/\(key)"
}
}
@@ -17,13 +17,14 @@
import Foundation
import CryptoKit
/// token nonisolatedactor await MainActor.run
public enum QiniuTokenSigner {
/// token
/// - Parameters:
/// - key: keyscope = bucketallow overridescope = bucket:key
/// - expiresIn: token 3600
public static func uploadToken(key: String? = nil, expiresIn: TimeInterval = 3600) -> String {
public nonisolated static func uploadToken(key: String? = nil, expiresIn: TimeInterval = 3600) -> String {
// 1. scope
let scope: String
if let key, !key.isEmpty {
@@ -59,7 +60,7 @@ public enum QiniuTokenSigner {
/// Base64URL: Base64 + -/ _ =
/// SDK `QNUrlSafeBase64.encodeData:`
private static func base64URLEncode(_ data: Data) -> String {
private nonisolated static func base64URLEncode(_ data: Data) -> String {
data.base64EncodedString()
.replacingOccurrences(of: "+", with: "-")
.replacingOccurrences(of: "/", with: "_")
+10 -2
View File
@@ -57,9 +57,17 @@ public actor QiniuUploader {
// token QiniuTokenSigner / msext QiniuManager
let token = QiniuTokenSigner.uploadToken(key: key)
// SDK 8.x`QNUploadManager.init()` `kQNDeprecated`
// `initWithConfiguration:` defaultConfigurationV2v2 defaultConfiguration
// initWithConfiguration: ObjC instancetype Swift
// IO responseInvalid
let cfg = QNConfiguration.defaultConfigurationV2()
guard let mgr = QNUploadManager(configuration: cfg) else {
throw QiniuUploadError.responseInvalid
}
let fileName = localFile.lastPathComponent
return try await withCheckedThrowingContinuation { (cont: CheckedContinuation<UploadedFile, Error>) in
let mgr = QNUploadManager()
let fileName = localFile.lastPathComponent
mgr.putFile(
localFile.path,
key: key,
+8 -7
View File
@@ -17,6 +17,9 @@ import Foundation
#if canImport(AMapFoundationKit)
import AMapFoundationKit
#endif
#if canImport(AMapLocationKit)
import AMapLocationKit
#endif
@MainActor
public enum AMapWrapper {
@@ -26,17 +29,15 @@ public enum AMapWrapper {
/// AppDelegate.didFinishLaunchingWithOptions
/// iOS 14+ updatePrivacyShow updatePrivacyAgree apiKey
/// updatePrivacyShow / updatePrivacyAgree AMapLocationManager
/// since 2.8.0 AMapServices
public static func bootstrap() {
#if canImport(AMapFoundationKit)
AMapLocationServices.updatePrivacyShow(.didShow, privacyInfo: .didContain)
AMapLocationServices.updatePrivacyAgree(.didAgree)
#if canImport(AMapFoundationKit) && canImport(AMapLocationKit)
AMapLocationManager.updatePrivacyShow(.didShow, privacyInfo: .didContain)
AMapLocationManager.updatePrivacyAgree(.didAgree)
AMapServices.shared().apiKey = apiKey
#else
// SDK no-op
#endif
}
}
#if canImport(AMapFoundationKit)
private typealias AMapLocationServices = AMapServices
#endif