XuqmGroup-iOSSDK/Sources/XuqmSDK/XuqmModuleRegistration.swift
XuqmGroup e016adbb71 chore(ci): 更新 Jenkins 配置以支持多模块版本管理
- 为 Android、Flutter、iOS 和 RN SDK 的 Jenkinsfile 添加模块化版本控制
- 引入版本升级策略选择(major/minor/patch)和自定义版本号功能
- 实现多模块独立版本管理和选择性构建发布
- 更新 iOS SDK Package.swift 以支持独立模块化库
- 修改 iOS SDK podspec 文件以适应新的标签命名约定
- 优化 Jenkins 构建流程以支持按需选择特定模块进行构建和发布
- 修复 iOS 测试中的可选类型转换问题以提高代码健壮性
2026-05-23 01:20:57 +08:00

76 行
2.6 KiB
Swift

@_exported import XuqmCoreSDK
@_exported import XuqmImSDK
@_exported import XuqmPushSDK
@_exported import XuqmUpdateSDK
@_exported import XuqmLicenseSDK
@_exported import XuqmFileSDK
import Foundation
/// Auto-registers all feature module hooks with XuqmSDK.shared.
/// Import `XuqmSDK` to get the full SDK experience (backward compatible).
extension XuqmSDK {
/// Register all module hooks. Called automatically when any module is first used.
public func registerModuleHooks() {
// License reader hook
licenseReader = {
guard let file = LicenseFileReader.read() else { return nil }
return LicenseFileData(
appKey: file.appKey,
appName: file.appName,
companyName: file.companyName,
packageName: file.packageName,
iosBundleId: file.iosBundleId,
harmonyBundleName: file.harmonyBundleName,
baseUrl: file.baseUrl,
serverUrl: file.serverUrl,
issuedAt: file.issuedAt,
expiresAt: file.expiresAt
)
}
// Initialize hook auto-start push if configured
onInitialize = { @MainActor config in
if config.autoRegisterPush {
Task { @MainActor in
try? await PushSDK.shared.start()
}
}
}
// Login hook connect IM and register push token
onLogin = { @MainActor userId, userSig in
try await ImSDK.shared.login(userId, userSig)
if let token = XuqmSDK.shared.cachedDeviceToken {
try await PushSDK.shared.registerToken(token, userId: userId)
}
}
// Logout hook disconnect IM and unregister push
onLogout = { @MainActor userId in
ImSDK.shared.disconnect()
try await PushSDK.shared.unregisterToken(userId: userId)
}
// Device token hook register with push service
onDeviceToken = { @MainActor token, userId in
try await PushSDK.shared.registerToken(token, userId: userId)
}
}
}
/// Convenience initializer that auto-registers module hooks.
/// This provides backward compatibility for code that does `import XuqmSDK`.
@MainActor
public enum XuqmSDKSetup {
private static var hooksRegistered = false
/// Ensure module hooks are registered. Idempotent.
public static func ensureHooksRegistered() {
guard !hooksRegistered else { return }
hooksRegistered = true
XuqmSDK.shared.registerModuleHooks()
}
}