supabase / supabase-swift Goto Github PK
View Code? Open in Web Editor NEWA Swift client for Supabase
Home Page: https://supabase.com/docs/reference/swift
License: MIT License
A Swift client for Supabase
Home Page: https://supabase.com/docs/reference/swift
License: MIT License
Is there any example code for google oauth? The example provided is used only email/password authentication.
Please introduce tags and releases to this package. As you know Swift Playgrounds 4 got released, but it only supports SPM packages by version number, not by branch. Thus it is currently impossible to use this SDK in a Playgrounds project.
I see in the gotrue RC pr the Google OAuth example was removed -
https://github.com/supabase-community/gotrue-swift/pull/37/files#diff-5040cbf573fdc1b4fc2384e97402e4a832b40b22e33b3ff33fd0568db8e35ab1
This was referenced in a few issues -
#39 (comment)
#32 (comment)
(FWIW, I was never able to get that example working.. it would never redirect back to my app)
Found another request for it
https://www.reddit.com/r/Supabase/comments/xbjkt5/guidance_needed_in_relation_to_supabase_auth_swift/
It's also being talked about in the community Discord channel (#swift) for something like this (?)
I'd also like to add that I'm new to Swift and would be interested in a full blown example app I could clone and learn from... with auth, realtime, and databasing. There's a lot of examples on the Supabase website, just none in Swift!
Guessing from contribution activity that it's not, but just wanted to check to be sure.. Hoping to use Google SSO in an app Im working on
had some success spitting this out
https://github.com/mstfy/spm-to-xcframework
/Users/johndpope/Desktop/spm-to-xcframework/.build/arm64-apple-macosx/release/spm-to-xcframework Sup
abase --path /Users/johndpope/Desktop/supabase-swift --output /Users/johndpope/Desktop/xcframework
it's helpful for bazel builds
Can't build my widget extension after using Supabase module: ld: symbol(s) not found for architecture arm64
Here is my code: https://gist.github.com/obito/2f750bc0df1f1b2faac350315dc88f88
Should not crash when trying to build, like on my iOS app.
No screenshots, but here is the full report dump: https://hastebin.com/share/ibakesinof.php
Macbook Air M1: Darwin macbook-2.local 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 21:00:41 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T8103 arm64
I don't really understand why this issue happens only on the widget extension part. It seems to look like it's failing to build because CMake/something was not build for the ARM64 architecture, when there shouldn't be any difference between an app and a widget (maybe?).
Is this library ready for use in a production app that can go in the App Store? If not, any ETA on when it would be ready by?
I am in the need to send my own Authorization
token in the header rather than using the Auth session that Supabase provides and currently its impossible to do so - or I haven't found the way to do it. It would be interesting to be able to add your own custom headers in the init of the client since its where you set your defaultHeaders
.
My proposal is to add in this init the ability to pass your own custom headers that are merged into the default Supabase ones.
public init(
supabaseURL: URL,
supabaseKey: String,
schema: String = "public",
httpClient: HTTPClient = HTTPClient(),
customHeaders: [String: String]? = nil
) {
self.supabaseURL = supabaseURL
self.supabaseKey = supabaseKey
self.schema = schema
self.httpClient = httpClient
defaultHeaders = [
"X-Client-Info": "supabase-swift/\(version)",
"apikey": supabaseKey,
]
if let customHeaders = customHeaders {
defaultHeaders = defaultHeaders.merging(customHeaders) { (_, new) in new }
}
auth = GoTrueClient(
url: supabaseURL.appendingPathComponent("/auth/v1"),
headers: defaultHeaders
)
}
This way the user can overwrite the headers if they consider it so - at their own risk.
I am trying to set up sign-in with apple for my Swift project. The account is being created on Supabase side but I can not see the email associated with the account.
trying to figure out what is the problem here and I am quite stumped.
I think it could be that the NotificationCenter.default.post Isn't posting and there for the observer isn't working either
I have also opened a ticket in the discord: https://discord.com/channels/839993398554656828/1084966472163536926
Hello,
Is it possible to sign up or login using third party logins such as Twitter?
Thank you
Socket is connected, channel is seemingly subscribed (it fires on "receive 'ok'")
It never fires on ".all" or any other events
Only when I unsubscribe "onClose" actually fires ("onError" never fires)
Replication is enabled on all tables, it doesn't work even on non-RLS tables
In API and Postgres logs I could only see "websocket" connections, didn't see any "subscription" logs if there are supposed to be any
@GRSouza please help
I'm setting it up like Realtime Swift docs say
URLSessionTransport is only available in iOS 13 or newer, but not constrained to that in RealtimeClient
What I find interesting is that the version constraint is commented out. Is this by accident?
Build attempts fail due to changes in PostgREST master branch
FunctionsClient
init changePostgrestClient
init changeFunctionsHTTPClient
removalPostgrestHTTPClient
removalSupabaseClient.swift
Should build without issue
Switching to the Release Candidate #45 most recent commit solves the issue (albeit not ideal)
.package(name: "Supabase", url: "https://github.com/supabase/supabase-swift.git", branch: "release-candidate")
It seems like shifting the master branch to tagged dependencies from here on would avoid issues like these popping up
We can simplify https://github.com/supabase-community/supabase-swift/blob/master/Sources/Supabase/SupabaseClient.swift#L90-L97 as all functions can now run on https://ref.supabase.co/functions/v1/function-name.
See supabase-js change here: https://github.com/supabase/supabase-js/pull/778/files
we're rolling out a header similar to Stripe's App-Data in all of the client libs so issues can be debugged more easily between the client and the backend
the javascript libs are done already: supabase/supabase-js#238
the format is: X-Client-Info: supabase-js/1.11.0
for client libs that wrap others (like how supabase-js wraps gotrue-js) we allow the wrapper lib to overwrite the wrapped lib's header (given that we can infer the gotrue-js version based on which supabase-js was used to make the call)
any help with rolling this out here would be incredible, it also ideally would be rolled out into the wrapped libs (postgrest-swift etc.)
The CRUD insert example found in README.MD is broken. This caused a lot of frustration getting started.
When running the example found in README.MD
let insertData = InsertModel(title: "Test", desc: "Test Desc")
let query = client.database
.from("{ Your Table Name }")
.select() // keep it empty for all, else specify returned data
.match(query: ["title" : insertData.title, "desc": insertData.desc])
.single()
Task {
do {
let response: InsertModel = try await query.execute().value
print("### Returned: \(response)")
} catch {
print("### Insert Error: \(error)")
}
}
Where InsertModel
is defined as (as the README says "Using the same model as before")
struct InsertModel: Encodable {
let id: Int? // you can choose to omit this depending on how you've setup your table
let title: String?
let desc: String?
}
You are greeted with the following error in XCode:
Cannot convert value of type 'Void' to specified type '[InsertModel]'
This is fixable by redefining InsertModel
as follows:
struct InsertModel: Encodable, Decodable {
let id: Int? // you can choose to omit this depending on how you've setup your table
let title: String?
let desc: String?
}
Which fixes this error. However, when attempting to cast to InsertModel
as follows in the example:
let response: InsertModel = try await query.execute().value
You receive the following error
typeMismatch(Swift.Dictionary<Swift.String, Any>, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected to decode Dictionary<String, Any> but found an array instead.", underlyingError: nil))
To address this, it must be fit into an array as follow:
let response: [InsertModel] = try await query.execute().value
This finally allows you to access the underlying data.
To reproduce, run the code found in the example README and perform the aforementioned changes.
let package = Package(
...
dependencies: [
...
.package(name: "Supabase", url: "https://github.com/supabase/supabase-swift.git", branch: "master"), // Add the package
],
targets: [
.target(
name: "YourTargetName",
dependencies: ["Supabase"] // Add as a dependency
)
]
)
Auto-refresh now works, but only half the time
It occasionally throws a PGRST301 error on query execution (401 on Supabase)
Retrying the query multiple times fixes this, but I don't think it's a good solution long-term
Maybe it issues a new token on query but passes only on the next one?
Any chance someone could find some time to add basic docs for Auth/Storage/Realtime? Would be super grateful! 🙏
I am trying to create a new client to test the supabase login in my swift-ui project, however when I try to create the client with:
let client = SupabaseClient(supabaseURL: "{ Supabase URL }", supabaseKey: "{ Supabase anonymous Key }")
I get the error Cannot convert value of type 'String' to expected argument type 'URL'
When using let client = SupabaseClient(supabaseURL: URL(string: "{ Supabase URL }"), supabaseKey: "{ Supabase anonymous Key }")
I get the error No exact matches in call to initializer
Am I doing something wrong or is the readme not up to date?
Create a client
I have this a test org and it's returning results fine using python
https://gist.github.com/johndpope/4bdf87792c034fadb157766c702253d0
When running same query
I get no results in swift version.
result: Optional(PostgREST.PostgrestResponse<()>(underlyingResponse: Get.Response<()>(value: (), response: <NSHTTPURLResponse: 0x600001263020> { URL: https://qfwzdkpmyzajmmvupgzy.supabase.co/rest/v1/tweets?select=* } { Status Code: 200, Headers {
"Access-Control-Allow-Origin" = (
"*"
);
"Alt-Svc" = (
"h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400"
);
"Content-Encoding" = (
br
);
"Content-Location" = (
"/tweets?select=%2A"
);
"Content-Type" = (
"application/json; charset=utf-8"
);
Date = (
"Thu, 17 Nov 2022 20:43:22 GMT"
);
Server = (
cloudflare
);
Vary = (
"Accept-Encoding"
);
Via = (
"kong/2.8.1"
);
"cf-cache-status" = (
DYNAMIC
);
"cf-ray" = (
"76bb4c4babd6a97a-SYD"
);
"content-profile" = (
public
);
"content-range" = (
"0-999/*"
);
"sb-gateway-version" = (
1
);
"x-kong-proxy-latency" = (
0
);
"x-kong-upstream-latency" = (
15
);
} }, data: 422860 bytes, task: LocalDataTask <47B6B060-DF8F-4921-AE38-CF831D362865>.<1>, metrics: Optional((Task Interval) <_NSConcreteDateInterval: 0x60000125f3e0> (Start Date) 2022-11-17 20:43:20 +0000 + (Duration) 2.450190 seconds = (End Date) 2022-11-17 20:43:22 +0000
(Redirect Count) 0
(Transaction Metrics) (Request) <NSMutableURLRequest: 0x60000101c320> { URL: https://qfwzdkpmyzajmmvupgzy.supabase.co/rest/v1/tweets?select=* }
(Response) <NSHTTPURLResponse: 0x600001262240> { URL: https://qfwzdkpmyzajmmvupgzy.supabase.co/rest/v1/tweets?select=* } { Status Code: 200, Headers {
"Access-Control-Allow-Origin" = (
"*"
);
"Alt-Svc" = (
"h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400"
);
"Content-Encoding" = (
br
);
"Content-Location" = (
"/tweets?select=%2A"
);
"Content-Type" = (
"application/json; charset=utf-8"
);
Date = (
"Thu, 17 Nov 2022 20:27:54 GMT"
);
Server = (
cloudflare
);
Vary = (
"Accept-Encoding"
);
Via = (
"kong/2.8.1"
);
"cf-cache-status" = (
DYNAMIC
);
"cf-ray" = (
"76bb35a7adf3a974-SYD"
);
"content-profile" = (
public
);
"content-range" = (
"0-999/*"
);
"sb-gateway-version" = (
1
);
"x-kong-proxy-latency" = (
1
);
"x-kong-upstream-latency" = (
15
);
} }
(Fetch Start) 2022-11-17 20:43:20 +0000
(Domain Lookup Start) (null)
(Domain Lookup End) (null)
(Connect Start) (null)
(Secure Connection Start) (null)
(Secure Connection End) (null)
(Connect End) (null)
(Request Start) 2022-11-17 20:43:20 +0000
(Request End) 2022-11-17 20:43:20 +0000
(Response Start) 2022-11-17 20:43:20 +0000
(Response End) 2022-11-17 20:43:20 +0000
(Protocol Name) (null)
(Proxy Connection) NO
(Reused Connection) NO
(Fetch Type) Local Cache
(Request Header Bytes) 0
(Request Body Transfer Bytes) 0
(Request Body Bytes) 0
(Response Header Bytes) 0
(Response Body Transfer Bytes) 0
(Response Body Bytes) 0
(Local Address) (null)
(Local Port) (null)
(Remote Address) (null)
(Remote Port) (null)
(TLS Protocol Version) 0x0000
(TLS Cipher Suite) 0x0000
(Cellular) NO
(Expensive) NO
(Constrained) NO
(Multipath) NO
(Request) <NSURLRequest: 0x60000101caf0> { URL: https://qfwzdkpmyzajmmvupgzy.supabase.co/rest/v1/tweets?select=* }
(Response) <NSHTTPURLResponse: 0x60000124e260> { URL: https://qfwzdkpmyzajmmvupgzy.supabase.co/rest/v1/tweets?select=* } { Status Code: 200, Headers {
"Access-Control-Allow-Origin" = (
"*"
);
"Alt-Svc" = (
"h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400"
);
"Content-Encoding" = (
br
);
"Content-Location" = (
"/tweets?select=%2A"
);
"Content-Type" = (
"application/json; charset=utf-8"
);
Date = (
"Thu, 17 Nov 2022 20:43:22 GMT"
);
Server = (
cloudflare
);
Vary = (
"Accept-Encoding"
);
Via = (
"kong/2.8.1"
);
"cf-cache-status" = (
DYNAMIC
);
"cf-ray" = (
"76bb4c4babd6a97a-SYD"
);
"content-profile" = (
public
);
"content-range" = (
"0-999/*"
);
"sb-gateway-version" = (
1
);
"x-kong-proxy-latency" = (
0
);
"x-kong-upstream-latency" = (
15
);
} }
(Fetch Start) 2022-11-17 20:43:20 +0000
(Domain Lookup Start) 2022-11-17 20:43:20 +0000
(Domain Lookup End) 2022-11-17 20:43:20 +0000
(Connect Start) 2022-11-17 20:43:20 +0000
(Secure Connection Start) 2022-11-17 20:43:20 +0000
(Secure Connection End) 2022-11-17 20:43:20 +0000
(Connect End) 2022-11-17 20:43:20 +0000
(Request Start) 2022-11-17 20:43:20 +0000
(Request End) 2022-11-17 20:43:20 +0000
(Response Start) 2022-11-17 20:43:22 +0000
(Response End) 2022-11-17 20:43:22 +0000
(Protocol Name) h3
(Proxy Connection) NO
(Reused Connection) NO
(Fetch Type) Network Load
(Request Header Bytes) 998
(Request Body Transfer Bytes) 0
(Request Body Bytes) 0
(Response Header Bytes) 295
(Response Body Transfer Bytes) 110951
(Response Body Bytes) 422860
(Local Address) 192.168.1.100
(Local Port) 62732
(Remote Address) 104.18.26.135
(Remote Port) 443
(TLS Protocol Version) 0x0304
(TLS Cipher Suite) 0x1301
(Cellular) NO
(Expensive) NO
(Constrained) NO
(Multipath) NO
)), count: nil))
override func viewDidLoad() {
super.viewDidLoad()
setupDatabase()
}
func setupDatabase() {
let SUPABASE_URL = URL(string:"https://qfwzdkpmyzajmmvupgzy.supabase.co")!
let ANON_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InFmd3pka3BteXpham1tdnVwZ3p5Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2NjgxMzAzMjYsImV4cCI6MTk4MzcwNjMyNn0.kEweOMrRSJ0mtOIXnsRmbNxf4yqoZAZf398jlGgSxtQ"
self.client = SupabaseClient(supabaseURL: SUPABASE_URL, supabaseKey: ANON_KEY)
Task {
await fetchRows();
}
}
func fetchRows() async {
let result = try? await self.client?.database.from("tweets").select(columns: "*").execute();
print("result:",result.debugDescription);
}
Steps to reproduce the behavior, please provide code snippets or a repository:
I'm on release-candidate branch
running python version - I get results back
but on ios - I get results = nil
If applicable, add screenshots to help explain your problem.
I've successfully used and got data from superbase in another project - not sure what's going on here.
maybe to do with async stuff?
Is there any chance we could create a new release with version 0.0.1 or something small? It would help when integrating this package with other packages where SPM requires a version number.
Add support for supabase-swift on Linux.
I'm trying to build a Swift on the server application and was hoping to use the Supabase SDK to do so, but not able to right now.
It looks like it mostly should work, but ran into an issue around some URLSession APIs that don't seem to be available on Linux. I believe it should be something you can work around, I found this blog post discussing the subject, and while I don't know the library's history I saw some #if canImport(FoundationNetworking)
checks in the code base already so I suspect some Linux support was at least attempted.
Using the REST API, but making this change would benefit more than just me, it would open up a whole class of possibilities for anyone using Supabase from the server.
This is the failed build log for the issue I'm running into.
/__w/SupabaseSample/SupabaseSample/.build/checkouts/storage-swift/Sources/SupabaseStorage/StorageHTTPClient.swift:4:25: error: cannot find type 'URLRequest' in scope
func fetch(_ request: URLRequest) async throws -> (Data, HTTPURLResponse)
^~~~~~~~~~
/__w/SupabaseSample/SupabaseSample/.build/checkouts/storage-swift/Sources/SupabaseStorage/StorageHTTPClient.swift:5:26: error: cannot find type 'URLRequest' in scope
func upload(_ request: URLRequest, from data: Data) async throws -> (Data, HTTPURLResponse)
^~~~~~~~~~
/__w/SupabaseSample/SupabaseSample/.build/checkouts/storage-swift/Sources/SupabaseStorage/StorageApi.swift:52:32: error: type of expression is ambiguous without more context
let (data, response) = try await http.fetch(request)
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/__w/SupabaseSample/SupabaseSample/.build/checkouts/storage-swift/Sources/SupabaseStorage/StorageApi.swift:53:32: error: type of expression is ambiguous without more context
if let mimeType = response.mimeType {
~~~~~~~~~^~~~~~~~
/__w/SupabaseSample/SupabaseSample/.build/checkouts/storage-swift/Sources/SupabaseStorage/StorageApi.swift:92:32: error: type of expression is ambiguous without more context
let (data, response) = try await http.upload(request, from: formData.data)
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/__w/SupabaseSample/SupabaseSample/.build/checkouts/storage-swift/Sources/SupabaseStorage/StorageHTTPClient.swift:4:60: error: 'HTTPURLResponse' is unavailable: This type has moved to the FoundationNetworking module. Import that module to use it.
func fetch(_ request: URLRequest) async throws -> (Data, HTTPURLResponse)
^~~~~~~~~~~~~~~
Foundation.HTTPURLResponse:2:18: note: 'HTTPURLResponse' has been explicitly marked unavailable here
public typealias HTTPURLResponse = AnyObject
^
/__w/SupabaseSample/SupabaseSample/.build/checkouts/storage-swift/Sources/SupabaseStorage/StorageHTTPClient.swift:5:78: error: 'HTTPURLResponse' is unavailable: This type has moved to the FoundationNetworking module. Import that module to use it.
func upload(_ request: URLRequest, from data: Data) async throws -> (Data, HTTPURLResponse)
^~~~~~~~~~~~~~~
Foundation.HTTPURLResponse:2:18: note: 'HTTPURLResponse' has been explicitly marked unavailable here
public typealias HTTPURLResponse = AnyObject
^
/__w/SupabaseSample/SupabaseSample/.build/checkouts/storage-swift/Sources/SupabaseStorage/StorageHTTPClient.swift:11:32: error: cannot find type 'URLRequest' in scope
public func fetch(_ request: URLRequest) async throws -> (Data, HTTPURLResponse) {
^~~~~~~~~~
/__w/SupabaseSample/SupabaseSample/.build/checkouts/storage-swift/Sources/SupabaseStorage/StorageHTTPClient.swift:11:67: error: 'HTTPURLResponse' is unavailable: This type has moved to the FoundationNetworking module. Import that module to use it.
public func fetch(_ request: URLRequest) async throws -> (Data, HTTPURLResponse) {
^~~~~~~~~~~~~~~
Foundation.HTTPURLResponse:2:18: note: 'HTTPURLResponse' has been explicitly marked unavailable here
public typealias HTTPURLResponse = AnyObject
^
error: Error Domain=NSCocoaErrorDomain Code=260 "The file doesn’t exist."
/__w/SupabaseSample/SupabaseSample/.build/checkouts/storage-swift/Sources/SupabaseStorage/StorageHTTPClient.swift:35:16: error: cannot find type 'URLRequest' in scope
_ request: URLRequest,
^~~~~~~~~~
/__w/SupabaseSample/SupabaseSample/.build/checkouts/storage-swift/Sources/SupabaseStorage/StorageHTTPClient.swift:37:28: error: 'HTTPURLResponse' is unavailable: This type has moved to the FoundationNetworking module. Import that module to use it.
) async throws -> (Data, HTTPURLResponse) {
^~~~~~~~~~~~~~~
Foundation.HTTPURLResponse:2:18: note: 'HTTPURLResponse' has been explicitly marked unavailable here
public typealias HTTPURLResponse = AnyObject
^
/__w/SupabaseSample/SupabaseSample/.build/checkouts/storage-swift/Sources/SupabaseStorage/StorageHTTPClient.swift:13:33: error: type 'URLSession' (aka 'AnyObject') has no member 'shared'
let dataTask = URLSession.shared.dataTask(with: request) { data, response, error in
~~~~~~~~~~ ^~~~~~
/__w/SupabaseSample/SupabaseSample/.build/checkouts/storage-swift/Sources/SupabaseStorage/StorageHTTPClient.swift:27:40: error: tuple type '(_, HTTPURLResponse)' (aka '(_, AnyObject)') is not convertible to tuple type '(Data, HTTPURLResponse)' (aka '(Data, AnyObject)')
continuation.resume(returning: (data, httpResponse))
^
/__w/SupabaseSample/SupabaseSample/.build/checkouts/storage-swift/Sources/SupabaseStorage/StorageHTTPClient.swift:39:29: error: type 'URLSession' (aka 'AnyObject') has no member 'shared'
let task = URLSession.shared.uploadTask(with: request, from: data) { data, response, error in
~~~~~~~~~~ ^~~~~~
/__w/SupabaseSample/SupabaseSample/.build/checkouts/storage-swift/Sources/SupabaseStorage/StorageHTTPClient.swift:53:40: error: tuple type '(_, HTTPURLResponse)' (aka '(_, AnyObject)') is not convertible to tuple type '(Data, HTTPURLResponse)' (aka '(Data, AnyObject)')
continuation.resume(returning: (data, httpResponse))
Listing buckets crashes the app.
When I try to use .listBuckets()
as mentioned here, my app throws an error (caught using fatalError
with the name "Error"). The error status code is 400.
try await client.storage.listBuckets()
I played around with Realtime based on the realtime-swift docs, but I just couldn't get it to work.
It would be great if you added docs for both of those features, since it has been months since anything changed with them.
MacOS: Monterey (12.2.2)
XCode Version 13.3 (13E113)
I seem to be having an issue getting this to work correctly. Trying to execute a query crashes as soon it begins.
Although it could be a problem with my code as I'm fairly new to swift.
My Environment variables are correct as I stepped through them before crash
import SwiftUI
import Supabase
struct ContentView: View {
@StateObject private var model = ContentViewModel()
var body: some View {
VStack {
List(model.lessons) { lesson in
Text("\(lesson.title): \(lesson.description)")
}
}
.onAppear {
model.getLessons()
}
}
}
class ContentViewModel: ObservableObject {
@Published var lessons: [Lesson] = []
let supabaseUrl = URL(string: ProcessInfo.processInfo.environment["SUPABASE_URL"]!)
let supabaseKey = ProcessInfo.processInfo.environment["SUPABASE_KEY"]!
lazy var client = SupabaseClient(supabaseURL: supabaseUrl!,supabaseKey: supabaseKey)
// Retrieve all lessons
func getLessons() {
print("Retrieving all todo's from database")
let query = client.database.from("lessons")
.select()
query.execute { results in
switch results {
case let .success(response):
let lessons = try? response.decoded(to: [Lesson].self)
self.lessons = lessons!
case let .failure(error):
print(error.localizedDescription)
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
let client = SupabaseClient(supabaseURL: SUPABASE_URL, supabaseKey: ANON_KEY)
how can a signed in user access database with row level security?
is there a way to switch in the jwt once we have it -
eg.
client.updateJWT( supabaseKey: authorisedJWT);
I'm working on a sign in with apple / nodejs - native login flow - but once I have the jwt - how can I then proceed to use it....
https://github.com/johndpope/Sign-in-with-Apple-for-supabase
When I login with goggle account, after signOut I can't sign in another google account. Step flow:
Expected: Show login screen with allow input new account
Actual: Auto login with old account
When trying to invoke any Edge Function from supabase-swift
client context (with or without invoke options) throws an error unacceptableStatusCode(404)
. Call does not register in the Edge Functions log browser, but it appears in the API Edge Network log browser as a 404
(see below) using a different invocation URL format:
functions-swift
https://xxx.supabase.co/functions/v1/preview-issue
https://xxx.functions.supabase.co/preview-issue
The function name is correct (preview-issue
) and can be accessed using Edge Functions API, so it appears that the invocation URL for functions-swift
uses an incorrect format:
Invoke a Edge Function using the following signature (after setting up your Supabase Swift client:
do {
try await client.functions.invoke(functionName: "preview-issue", invokeOptions: .init(headers: ["param": "some-string"]))
} catch {
throw error
}
Log ID
4edd9ee6-9cff-47c3-a476-8426515f3ad2
Log Timestamp (UTC)
2023-02-12T12:24:31.132Z
Log Event Message
POST | 404 | 213.205.242.39 | 79854d3a4d27777a | https://xxx.supabase.co/functions/v1/preview-issue
Log Metadata
[
{
"request": [
{
"headers": [
{
"accept": "application/json",
"cf_cache_status": null,
"cf_connecting_ip": "213.205.242.39",
"cf_ipcountry": "GB",
"cf_ray": "79854d3a4d27777a",
"content_length": "0",
"content_location": null,
"content_range": null,
"content_type": null,
"date": null,
"host": "xxx.supabase.co",
"referer": null,
"sb_gateway_version": null,
"user_agent": "iOS/1 CFNetwork/1402.0.8 Darwin/22.3.0",
"x_client_info": "functions-swift/0.2.0",
"x_forwarded_proto": "https",
"x_forwarded_user_agent": null,
"x_kong_proxy_latency": null,
"x_kong_upstream_latency": null,
"x_real_ip": "213.205.242.39"
}
],
"host": "xxx.supabase.co",
"method": "POST",
"path": "/functions/v1/preview-issue",
"port": null,
"protocol": "https:",
"sb": [],
"search": null,
"url": "https://xxx.supabase.co/functions/v1/preview-issue"
}
],
"response": [
{
"headers": [
{
"cf_cache_status": "DYNAMIC",
"cf_ray": "79854d3a7723777a-LHR",
"content_length": "48",
"content_location": null,
"content_range": null,
"content_type": "application/json; charset=utf-8",
"date": "Sun, 12 Feb 2023 12:24:31 GMT",
"sb_gateway_mode": null,
"sb_gateway_version": "1",
"transfer_encoding": null,
"x_kong_proxy_latency": null,
"x_kong_upstream_latency": null
}
],
"origin_time": 37,
"status_code": 404
}
]
}
]
16.1
5.7
14.2
supabase-swift
: 0.1.2
functions-swift
: 0.2.0
It would be great a GoTrueClient
to be injected as a parameter to SupabaseClient initializer.
We have a specific Keychain configuration that we need to inject to the GoTrueClient
(whose initializers already support injecting their own KeychainStorage/GoTrueLocalStorage
. Our app will not be able to use the defacto Keychain location that is being provided in the GoTrueClient(...)
init that this initializer is using.
This could be as easy as allowing a new constructor
public init(
supabaseURL: URL,
supabaseKey: String,
schema: String = "public",
headers: [String: String] = [:],
httpClient: HTTPClient = HTTPClient(),
authClient: GoTrueClient
) {
It seems that the auth client does depend on the headers, so maybe allowing some kind of convenience method on GoTrueClient(...)
to construct it based upon the existing supabaseURL
and supabaseKey
which are added via the defaultHeaders property, would be helpful.
Instead of being provided to the initializer, the auth
property could become a var
for an automatic get
or there could be another function like setAuthClient(...)
that is exposed. But that would probably introduce some weird conditions that are tougher to reason about rather than just injecting in the init(...)
If either approach is acceptable, I'm happy to write it up and put up a PR.
Thanks.
which url should i use in redirect url in implementing social auth? Can u provide example?
What can I do to enable support for IOS12?
TX.
Attempting to login via:
client.auth.signIn(email: email,
password: password,
completion: { session in
print("login result ", session)
})
but getting a runtime crash:
Fatal error: Attempted to read an unowned reference but object 0x600001c8fc60 was already deallocated
CoreSimulator 776.3 - Device: iPhone 13 Pro Max (B3F3EB94-461D-4424-95F2-9BC730D4FB80) - Runtime: iOS 15.0 (19A339) - DeviceType: iPhone 13 Pro Max
Running iOS 15, Xcode 13 in a SwiftUI application
The code for adding a Todo throws several errors.
There appears to be an error in the JSON serialization and the client database insertion says "from" when the method should be "form. Changing that part works. But I'm unsure if the data is being properly serialized.
do {
let jsonData: Data = try JSONEncoder().encode(todo)
let jsonDict = try JSONSerialization.jsonObject(with: jsonData, options: .allowFragments)
try client.database.form("todos")
.insert(values: jsonDict as! [String : Any])
.execute { results in
print(results)
// Handle response
}
} catch {
print("Error inserting the todo: \(error)")
}
Steps to reproduce the behavior, please provide code snippets or a repository:
The following error messages appear:
Ideally the code wouldn't throw any error messages.
Using this code I insert a row into a todo table.
Expectation was, that execute returns the row but it doesn‘t.
But I need the inserted row because „id“ is an autogenerated column.
Any way to achieve this?
func createTodo(withTitle title: String) async {
let todo = Todo(id: nil, title: title, done: false)
let query = client
.database
.from("todos")
.insert(values: todo)
query.execute { results in
switch results {
case let .success(result):
print (result)
// self.todos.append(result.data) // I can‘t do that sice I receive no resulting data
case let .failure(error):
Print(error.localizedDescription)
}
}
}
If my JWT has expired since I last called supabaseClient.auth.session
, and I try to execute a command using supabaseClient.database
, I get an error about the JWT being expired. I have to work around this by calling _ = supabaseClient.auth.session
before every database call to force it to refresh the token.
I would expect the session to automatically be refreshed before attempting the database operation.
The compiler complains when integrating supabase-swift
into a project:
error: The package product 'Supabase' cannot be used as a dependency of this target because it uses unsafe build flags. (in target 'MyApp' from project 'MyApp')
Steps to reproduce the behavior, please provide code snippets or a repository:
Should be able to compile.
If applicable, add screenshots to help explain your problem.
macOS Ventura 10.13.1
Xcode 14.2 (14C18)
Add any other context about the problem here.
We are developing a digital signage app for Apple TV (tvOS) and are considering to use Supabase as our backend service. While creating a proof of concept I stumbled upon a problem with authenticating. Since there is no web browser on tvOS the traditional auth flow won't work.
Instead the user needs to sign in on another device and we need to set auth tokens manually on the SupabaseClient
instance in our tvOS app. E.g. there might be a companion sign-in app on iOS that transfers auth tokens securely over to the tvOS app.
But as of now there is no way to set auth tokens manually on the client itself.
In supabase-js
we have a method called setAuth()
that lets you override the access token. Since the app basically does not have any user interaction at all, we also need to set the refresh token in order to stay authenticated while the app shows its content.
The refreshed GoTrue
token is not being passed down to other clients (PostgREST
), returning the error PostgrestError(details: nil, hint: nil, code: nil, message: "JWT expired")
.
This is related to supabase-community/gotrue-swift#19
I am trying to run .list over a storage bucket to get back all the images or files inside of the bucket
check to see this discord conversation with myself and GaryAustin : https://discord.com/channels/839993398554656828/1082418604206739527
I can't seem to figure out why .list won't show any of my files and I can upload and download them.
I have a table called fun_facts
with the following columns:
id
: int (primary key)
content
: text
keywords
: text
tag
: text
Here's an example of a row:
id
: 123
content
: "A crocodile cannot stick its tongue out"
keywords
: "impossible animals body funny"
tag
: "fact123"
Using the Supabase Swift client, what's the best/recommended way to search across multiple table columns? I want the example row above to show up if I search for terms such as the following:
Thanks in advance!
Some headers aren't set when initializing a SupabaseClient
and make it impossible to use the storage module
Initialize a SupabaseClient
and use any method from the subclass storage
(e.g. client.storage.listBuckets()
)
This issue is related to this issue from storage-swift but it needs to be fixed from this repo and not from supabase-community/storage-swift.
Please see this comment fro more information.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.