I’m trying to use TDLibKit (Swift wrapper for Telegram Database Library) in a SwiftUI project on an Intel Mac. I added TDLibKit via Swift Package Manager, which depends on TDLibFramework. TDLibFramework has no .xcframework or Xcode project, only source code compiled by SPM. Via SPM i cannot assign Targets/Frameworks, Libraries.../Embed & Sign.
Attempting to add TDLibFramework manually (Embed & Sign) causes: duplicate output file errors, CodeSign errors, and build failures. Trying forks or pointing TDLibKit to a fork of TDLibFramework causes failed fetch, invalid manifest, and dependency resolution errors. Clean builds, deleting DerivedData, and resetting Package.resolved don’t help. A fresh SwiftUI project with no code (just "hello world) compiles, but as soon i put the code to call the tdlib library, i got a lot of errors. Question: What is the proper workflow to integrate TDLibKit + TDLibFramework in Xcode on an Intel Mac without running into duplicate tasks, code signing, or dependency resolution issues? How can I test TDLibKit reliably without trying to embed frameworks manually? I'm on Xcode 16.3. Sequoia 15.6.1
import Foundation
import TDLibKit
@MainActor
final class TelegramManager: ObservableObject {
private let client = TDLibClientManager()
@Published var log: String = "Aguardando TDLib..."
private var isReady = false
func start(apiId: Int, apiHash: String) {
let params = TDLibParameters(
apiId: apiId,
apiHash: apiHash,
systemLanguageCode: "pt",
deviceModel: "iPhone",
systemVersion: "iOS",
applicationVersion: "1.0",
databaseDirectory: "tdlib",
filesDirectory: "tdlib_files",
useMessageDatabase: true,
useSecretChats: false,
useTestDc: false,
enableStorageOptimizer: true
)
Task {
do {
try await client.send(query: .setTdlibParameters(params))
appendLog("✅ TDLib configurada")
await listenAuthorization()
} catch {
appendLog("❌ Erro ao configurar TDLib: \(error)")
}
}
}
private func listenAuthorization() {
Task {
for await update in client.updates {
switch update {
case .updateAuthorizationState(let auth):
switch auth.authorizationState {
case .authorizationStateWaitPhoneNumber:
appendLog("📞 Aguardando telefone…")
case .authorizationStateWaitCode:
appendLog("🔑 Aguardando código…")
case .authorizationStateReady:
isReady = true
appendLog("✅ TDLib pronta")
default: break
}
default: break
}
}
}
}
func sendPhone(_ phone: String) {
guard !isReady else { return }
Task {
do {
try await client.send(query: .setAuthenticationPhoneNumber(phoneNumber: phone, settings: .init()))
appendLog("📤 Telefone enviado")
} catch {
appendLog("❌ Erro ao enviar telefone: \(error)")
}
}
}
func sendCode(_ code: String) {
guard !isReady else { return }
Task {
do {
try await client.send(query: .checkAuthenticationCode(code: code))
appendLog("📤 Código enviado")
} catch {
appendLog("❌ Erro ao enviar código: \(error)")
}
}
}
func sendSilentText(toUsername username: String, text: String) {
guard isReady else { return }
let cleanUsername = username.replacingOccurrences(of: "@", with: "")
Task {
do {
let chat = try await client.send(query: .searchPublicChat(username: cleanUsername))
let msg = InputMessageText(text: FormattedText(text: text, entities: []),
clearDraft: false,
disableWebPagePreview: true)
try await client.send(query: .sendMessage(chatId: chat.id, inputMessageContent: msg))
appendLog("✅ Mensagem enviada para @\(cleanUsername)")
} catch {
appendLog("❌ Erro ao enviar mensagem: \(error)")
}
}
}
private func appendLog(_ text: String) {
DispatchQueue.main.async {
self.log += "\n" + text
}
}
}
only TDLibKit appears on Target
only TDLibkit appears as available
If i try to build, there's multiple errors
I tried everything possible: cloning the git repository and tried to manually integrate on project, i've tried to install it via cocoapods, homebrew, forking to my github repo changing package.swift to dynamic. I don't know what else to do.
send()is aTDLibClientmethod not aTDLibClientManagerif I refer to github.com/Swiftgram/TDLibKit/blob/main/Sources/TDLibKit/…