- Xcode 15.0+
- A Google Cloud account
- A Supabase account
IMPORTANT: Before you can run the app, you need to create your configuration file:
-
Copy the template file:
cp SupabaseConfig.swift.template SupabaseConfig.swift
-
Edit
SupabaseConfig.swift
and replace the placeholder values with your actual credentials:YOUR_SUPABASE_URL_HERE
→ Your Supabase project URLYOUR_SUPABASE_ANON_KEY_HERE
→ Your Supabase anon/public keyYOUR_GOOGLE_CLIENT_ID_HERE
→ Your Google OAuth client ID
Note: The SupabaseConfig.swift
file is gitignored to protect your credentials. Only the template file is tracked in git.
Add these Swift packages to your Xcode project:
- Supabase Swift:
https://github.com/supabase/supabase-swift
- Google Sign-In:
https://github.com/google/GoogleSignIn-iOS
- In Xcode, go to File > Add Package Dependencies
- Paste the URLs above one by one
- Click Add Package for each
-
Go to Google Cloud Console
-
Create a new project or select an existing one
-
Enable the Google+ API:
- Go to APIs & Services > Library
- Search for "Google+ API"
- Click Enable
-
Create OAuth 2.0 credentials:
- Go to APIs & Services > Credentials
- Click Create Credentials > OAuth 2.0 Client IDs
- Choose macOS as application type
- Add your app's bundle identifier
- Copy the Client ID (you'll need this for Step 0)
- Go to supabase.com and create a new project
- Wait for the project to be fully initialized
- In your Supabase dashboard, go to Authentication > Providers
- Find Google and toggle it ON
- Paste your Google Client ID and Client Secret from Step 2
- Add your redirect URL:
https://your-project.supabase.co/auth/v1/callback
- IMPORTANT: Disable nonce validation (to avoid nonce mismatch errors)
- Go to Settings > API
- Copy your Project URL and anon/public key (you'll need these for Step 0)
In your Supabase dashboard, go to SQL Editor and run this SQL:
-- Create hobbies table
CREATE TABLE hobbies (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID REFERENCES auth.users(id) ON DELETE CASCADE,
name TEXT NOT NULL,
description TEXT DEFAULT '',
color TEXT DEFAULT '#007AFF',
theme TEXT DEFAULT 'green',
total_time DOUBLE PRECISION DEFAULT 0,
sessions JSONB DEFAULT '[]'::jsonb,
created_date TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Enable Row Level Security
ALTER TABLE hobbies ENABLE ROW LEVEL SECURITY;
-- Create policy to allow users to only see their own hobbies
CREATE POLICY "Users can view own hobbies"
ON hobbies FOR SELECT
USING (auth.uid() = user_id);
CREATE POLICY "Users can insert own hobbies"
ON hobbies FOR INSERT
WITH CHECK (auth.uid() = user_id);
CREATE POLICY "Users can update own hobbies"
ON hobbies FOR UPDATE
USING (auth.uid() = user_id);
CREATE POLICY "Users can delete own hobbies"
ON hobbies FOR DELETE
USING (auth.uid() = user_id);
If you already have a hobbies table without the theme column, run this migration:
-- Add theme column to existing hobbies table
ALTER TABLE hobbies ADD COLUMN theme TEXT DEFAULT 'green';
-- Update existing hobbies with themes in rotation (green, red, blue)
WITH numbered_hobbies AS (
SELECT id, ROW_NUMBER() OVER (PARTITION BY user_id ORDER BY created_date) - 1 as row_num
FROM hobbies
)
UPDATE hobbies
SET theme = CASE
WHEN (SELECT row_num FROM numbered_hobbies WHERE numbered_hobbies.id = hobbies.id) % 3 = 0 THEN 'green'
WHEN (SELECT row_num FROM numbered_hobbies WHERE numbered_hobbies.id = hobbies.id) % 3 = 1 THEN 'red'
ELSE 'blue'
END
WHERE theme IS NULL OR theme = 'green';
This step is now done in Step 0! Make sure you've created your SupabaseConfig.swift
file from the template.
If you encounter URL handling issues:
- In Xcode, select your app target
- Go to Info > URL Types
- Add a new URL Type with:
- Identifier:
com.googleusercontent.apps.YOUR_CLIENT_ID
- URL Schemes: Your Google Client ID (reversed)
- Identifier:
- Build and run your app
- You should see the login screen
- Click "Sign in with Google"
- Complete the Google OAuth flow
- You should be redirected back to your app and see the main hobby tracking interface
- "Could not find GoogleService-Info.plist" - This is expected since we're using the configuration file approach
- Authentication errors - Check that your Google Client ID is correct in both Google Cloud Console and Supabase
- Nonce validation errors - Make sure you've disabled nonce validation in Supabase Auth settings
- Database errors - Ensure the SQL schema was created successfully
- Build errors - Make sure both Swift packages are properly added
- Missing config file - Make sure you've copied and configured
SupabaseConfig.swift
from the template
In Supabase dashboard > API Docs, you can test your connection using the auto-generated API calls.
If you're setting up this project:
- Never commit your actual credentials - The
SupabaseConfig.swift
file is gitignored - Always use the template - Copy
SupabaseConfig.swift.template
toSupabaseConfig.swift
- Keep credentials secure - Don't share your config file or commit it accidentally
Once setup is complete:
- Users can sign in with Google
- Each user has their own isolated hobby data
- All existing functionality remains the same
- Users can sign out from the profile menu in the bottom-left sidebar
Your app now has full backend support with user authentication! 🎉