1
Create a new iOS app in Xcode
- Click Create New Project
- Select iOS App and click Next
- Name your project something like “BijectionQuickstart”
- Ensure Language is set to Swift and User Interface is SwiftUI
- Click Next
2
Configure dependencies
- Click on the top-level BijectionQuickstart app container in the project navigator on the left
- Click on BijectionQuickstart under the PROJECT heading
- Click the Package Dependencies tab
- Click the + button (See Screenshot)
- Paste
into the search box and press enter
- When the
bijection-swiftpackage loads, click the Add Package button - In the Package Products dialog, select BijectionQuickstart in the Add to Target dropdown
- Click the Add Package button
3
Add a Bijection backend
Open a terminal and
cd to the directory for the Xcode project you
created. Run bijection init to add a bijection/ folder, where you write
your backend functions, with a sample schema, query and mutation, and
bijection.json.4
Start Bijection
Log this machine in to Bijection, once per machine, then start a Bijection
dev deployment. The first run of
bijection dev creates it and saves its
URL in .env.local as BIJECTION_URL; the command then keeps running to
push your functions on every change.Bijection’s hosted service is not yet open for public sign-up, and the CLI
has no default management service. Before running
bijection login, set
BIJECTION_MANAGEMENT_URL to the management service URL you were given, in
your shell’s startup file so that every later bijection command sees it too:5
Create sample data for your database
Create a new
sampleData.jsonl file in your Swift project directory with
these contents6
Add the sample data to a table called tasks in your database
Open another terminal tab by pressing ⌘+T which should open in your Swift
project directory and run
7
Declare the tasks table
bijection init created bijection/schema.ts, which declares the tables of
your database, starting with a sample messages table. Add a tasks table
beside it. The schema gives your functions TypeScript types, and Bijection
enforces it at runtime.bijection/schema.ts
8
Expose a database query
Create a
tasks.ts file in the bijection/ directory within your Swift
project with the following contents9
Create a Swift struct
Back in Xcode, create a
struct at the bottom of the ContentView file to
match the sample data10
Connect the app to your backend
- Get the deployment URL of your dev server
with
cat .env.local | grep BIJECTION_URL - Create a
BijectionClientinstance near the top of the file, just above theContentViewstruct
11
Create your UI
Replace the default
ContentView with the following code that will
refresh the list of todo items whenever the backend data changes.12
Run the app
- Press ⌘+R or click Product → Run
- You can also try adding, updating or
deleting documents in your
taskstable atconsole.bijection.com- the app will update with the changes in real-time.