Skip to content

Commit 64309c0

Browse files
committed
Start updating README
1 parent 9bdbb17 commit 64309c0

File tree

3 files changed

+53
-15
lines changed

3 files changed

+53
-15
lines changed

README.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
1-
# `supabase-swift`
1+
# supabase-swift
22

3-
Swift Client library to interact with Supabase.
3+
Supabase client for swift. Mirrors the design of [supabase-js](https://github.com/supabase/supabase-js/blob/master/README.md)
44

5-
- Documentation: https://supabase.io/docs/reference/swift/supabase-client
5+
## Installation
66

7-
## Sponsors
7+
Swift Package Manager:
88

9-
We are building the features of Firebase using enterprise-grade, open source products. We support existing communities wherever possible, and if the products don’t exist we build them and open source them ourselves. Thanks to these sponsors who are making the OSS ecosystem better for everyone.
9+
Add the following lines to your `Package.swift` file:
10+
```swift
11+
let package = Package(
12+
...
13+
dependencies: [
14+
...
15+
.package(name: "Supabase", url: "https://github.com/supabase/supabase-swift.git", .branch("main")),
16+
],
17+
targets: [
18+
.target(
19+
name: "YourTargetName",
20+
dependencies: ["Supabase"] // Add as a dependency
21+
)
22+
]
23+
)
24+
```
1025

11-
[![New Sponsor](https://user-images.githubusercontent.com/10214025/90518111-e74bbb00-e198-11ea-8f88-c9e3c1aa4b5b.png)](https://github.com/sponsors/supabase)
26+
If you're using Xcode, [use this guide](https://developer.apple.com/documentation/swift_packages/adding_package_dependencies_to_your_app) to add `supabase-swift` to your project. Use `https://github.com/supabase/supabase-swift.git` for the url when Xcode asks.

Sources/Supabase/Supabase.swift

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,38 @@ import PostgREST
33
import Realtime
44
import SupabaseStorage
55

6-
public class SupabaseClient {
7-
var supabaseUrl: String
8-
var supabaseKey: String
9-
var schema: String
10-
var restUrl: String
11-
var realtimeUrl: String
12-
var authUrl: String
13-
var storageUrl: String
6+
/**
7+
The main class for accessing Supabase functionality
8+
9+
Initialize this class using `.init(supabaseURL: String, supabaseKey: String)`
10+
11+
There are four main classes contained by the `Supabase` class.
12+
1. `auth`
13+
2. `database`
14+
3. `realtime`
15+
4. `storage`
16+
Each class listed is available under `Supabase.{name}`, eg: `Supabase.auth`
17+
*/
18+
public class Supabase {
19+
private var supabaseUrl: String
20+
private var supabaseKey: String
21+
private var schema: String
22+
private var restUrl: String
23+
private var realtimeUrl: String
24+
private var authUrl: String
25+
private var storageUrl: String
1426

1527
public var auth: GoTrueClient
1628

29+
/// Storage client for Supabase.
1730
public var storage: SupabaseStorageClient {
1831
var headers: [String: String] = [:]
1932
headers["apikey"] = supabaseKey
2033
headers["Authorization"] = "Bearer \(auth.session?.accessToken ?? supabaseKey)"
2134
return SupabaseStorageClient(url: storageUrl, headers: headers)
2235
}
2336

37+
/// Database client for Supabase.
2438
public var database: PostgrestClient {
2539
var headers: [String: String] = [:]
2640
headers["apikey"] = supabaseKey
@@ -30,6 +44,12 @@ public class SupabaseClient {
3044

3145
private var realtime: RealtimeClient
3246

47+
/// Init `Supabase` with the provided parameters.
48+
/// - Parameters:
49+
/// - supabaseUrl: Unique Supabase project url
50+
/// - supabaseKey: Supabase anonymous API Key
51+
/// - schema: Database schema name, defaults to `public`
52+
/// - autoRefreshToken: Toggles whether `Supabase.auth` automatically refreshes the auth token. Defaults to `true`
3353
public init(
3454
supabaseUrl: String,
3555
supabaseKey: String,
@@ -52,3 +72,6 @@ public class SupabaseClient {
5272
realtime = RealtimeClient(endPoint: realtimeUrl, params: ["apikey": supabaseKey])
5373
}
5474
}
75+
76+
@available(*, deprecated, message: "Use `Supabase` instead of `SupabaseClient`")
77+
typealias SupabaseClient = Supabase

Tests/SupabaseTests/SupabaseTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import XCTest
44
@testable import Supabase
55

66
final class SupabaseTests: XCTestCase {
7-
var supabase = SupabaseClient(
7+
var supabase = Supabase(
88
supabaseUrl: SupabaseTests.supabaseUrl(), supabaseKey: SupabaseTests.supabaseKey())
99

1010
static func supabaseUrl() -> String {

0 commit comments

Comments
 (0)