You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Supabase与Swift集成报错:Xcode提示‘Extra trailing closure passed in call’

解决Supabase Swift SDK中"Extra trailing closure passed in call"错误

你的问题出在Supabase Swift SDK的execute()方法调用上——当前版本的SDK已经将execute()改为异步函数(支持async/await),不再接受尾随闭包参数,直接传入闭包就会触发这个错误。

修正后的fetchConversations函数如下:

func fetchConversations(for userId: UUID, completion: @escaping (Result<[Conversation], Error>) -> Void) {
    Task {
        do {
            let response = try await client.database
                .from("Chats")
                .select("chat_id, created_by, created_at")
                .eq("created_by", value: userId.uuidString)
                .execute()
            
            let conversations = try JSONDecoder().decode([Conversation].self, from: response.data)
            completion(.success(conversations))
        } catch {
            completion(.failure(error))
        }
    }
}

关键修改点:

  • 将原有的闭包调用改为try await异步执行execute()
  • 把所有逻辑包裹在Task中,和你已有的registerWithPhone、loginWithPhone等方法保持一致的异步处理风格
  • 错误处理统一通过do-catch捕获,再传递给completion回调

这样修改后,既符合Supabase SDK的最新用法,也能解决Xcode的编译错误。

内容的提问来源于stack exchange,提问作者Franciscuzzo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 23:43:28