mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
docs: swift guide for connect (#27541)
* connect swift guide for studio * remove Model wording Co-authored-by: Guilherme Souza <grsouza@pm.me> * Update apps/studio/components/interfaces/Home/Connect/content/swift/supabaseswift/content.tsx Co-authored-by: Guilherme Souza <grsouza@pm.me> * changed to newer components Co-authored-by: Guilherme Souza <grsouza@pm.me> * Fix a merge conflict. --------- Co-authored-by: Guilherme Souza <grsouza@pm.me> Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
This commit is contained in:
2 files changed
+98
No files matched your search
@@ -206,6 +206,20 @@ export const MOBILES: ConnectionType[] = [
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'swift',
|
||||
label: 'Swift',
|
||||
icon: 'swift',
|
||||
guideLink: 'https://supabase.com/docs/guides/getting-started/tutorials/with-swift',
|
||||
children: [
|
||||
{
|
||||
key: 'supabaseswift',
|
||||
label: 'supabase-swift',
|
||||
children: [],
|
||||
icon: 'supabase',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
key: 'androidkotlin',
|
||||
label: 'Android Kotlin',
|
||||
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
import type { ContentFileProps } from 'components/interfaces/Home/Connect/Connect.types'
|
||||
|
||||
import {
|
||||
ConnectTabs,
|
||||
ConnectTabTriggers,
|
||||
ConnectTabTrigger,
|
||||
ConnectTabContent,
|
||||
} from 'components/interfaces/Home/Connect/ConnectTabs'
|
||||
import SimpleCodeBlock from 'components/to-be-cleaned/SimpleCodeBlock'
|
||||
|
||||
const ContentFile = ({ projectKeys }: ContentFileProps) => {
|
||||
return (
|
||||
<ConnectTabs>
|
||||
<ConnectTabTriggers>
|
||||
<ConnectTabTrigger value="Supabase.swift" />
|
||||
<ConnectTabTrigger value="Todo.swift" />
|
||||
<ConnectTabTrigger value="ContentView.swift" />
|
||||
</ConnectTabTriggers>
|
||||
|
||||
<ConnectTabContent value="Supabase.swift">
|
||||
<SimpleCodeBlock className="swift" parentClassName="min-h-72">
|
||||
{`
|
||||
import Foundation
|
||||
import Supabase
|
||||
|
||||
let supabase = SupabaseClient(
|
||||
supabaseURL: URL(string: "${projectKeys.apiUrl ?? 'your-project-url'}")!,
|
||||
supabaseKey: "${projectKeys.anonKey ?? 'your-anon-key'}"
|
||||
)
|
||||
`}
|
||||
</SimpleCodeBlock>
|
||||
</ConnectTabContent>
|
||||
|
||||
<ConnectTabContent value="Todo.swift">
|
||||
<SimpleCodeBlock className="swift" parentClassName="min-h-72">
|
||||
{`
|
||||
import Foundation
|
||||
|
||||
struct Todo: Identifiable, Decodable {
|
||||
var id: Int
|
||||
var title: String
|
||||
}
|
||||
`}
|
||||
</SimpleCodeBlock>
|
||||
</ConnectTabContent>
|
||||
|
||||
<ConnectTabContent value="ContentView.swift">
|
||||
<SimpleCodeBlock className="swift" parentClassName="min-h-72">
|
||||
{`
|
||||
import Supabase
|
||||
import SwiftUI
|
||||
|
||||
struct ContentView: View {
|
||||
@State var todos: [Todo] = []
|
||||
|
||||
var body: some View {
|
||||
NavigationStack {
|
||||
List(todos) { todo in
|
||||
Text(todo.title)
|
||||
}
|
||||
.navigationTitle("Todos")
|
||||
.task {
|
||||
do {
|
||||
todos = try await supabase.from("todos").select().execute().value
|
||||
} catch {
|
||||
debugPrint(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#Preview {
|
||||
ContentView()
|
||||
}
|
||||
|
||||
`}
|
||||
</SimpleCodeBlock>
|
||||
</ConnectTabContent>
|
||||
</ConnectTabs>
|
||||
)
|
||||
}
|
||||
|
||||
export default ContentFile
|
||||
Reference in new issue
Block a user