Skip to content

Development Setup

Set up your development environment for Toss.

Prerequisites

Ensure you have all dependencies installed:

./scripts/setup.sh

Required: - Rust 1.75+ - Flutter 3.24+ - Platform-specific build tools (Xcode, Android SDK, etc.)

First Steps

1. Clone Repository

git clone https://github.com/rennerdo30/toss-share.git
cd toss-share

2. Verify FFI Setup

Before generating FFI bindings, verify everything is configured:

make verify-ffi

This checks: - ✅ Rust toolchain - ✅ Flutter SDK - ✅ flutter_rust_bridge_codegen - ✅ Configuration files - ✅ Rust compilation

3. Generate FFI Bindings

make generate-ffi

This generates: - flutter_app/lib/src/rust/api.dart - Dart bindings - rust_core/src/api/toss_api.h - C header

4. Build the Project

# Build Rust core
make build-rust

# Build Flutter app
make build-flutter

# Or build everything
make build

5. Run the Application

# Run Flutter app
make run-flutter

# Or manually
cd flutter_app && flutter run

Development Workflow

Daily Development

  1. Start Development

    # Verify setup
    make verify-ffi
    
    # Generate code (if needed)
    make generate-ffi
    
    # Run app
    make run-flutter
    

  2. Make Changes

  3. Edit Rust code in rust_core/src/
  4. Edit Flutter code in flutter_app/lib/
  5. Update FFI API in rust_core/src/api/mod.rs

  6. After Rust API Changes

    # Regenerate FFI bindings
    make generate-ffi
    

  7. Test Changes

    # Run tests
    make test-all
    
    # Or individually
    make test-rust
    make test-flutter
    

Code Quality

# Format code
make fmt

# Lint code
make lint

# Run all checks
make check

Project Structure

toss/
├── rust_core/          # Rust core library
│   └── src/
│       ├── api/       # FFI API (mod.rs)
│       ├── clipboard/ # Clipboard operations
│       ├── crypto/    # Encryption
│       ├── network/   # Networking (P2P, Relay)
│       └── storage/   # SQLite storage
├── flutter_app/       # Flutter application
│   └── lib/
│       ├── src/
│       │   ├── core/  # Services, providers
│       │   └── features/ # UI screens
│       └── rust/      # Generated FFI bindings
├── relay_server/      # Relay server (optional)
└── docs/              # Documentation

Common Tasks

Generate FFI Bindings

make generate-ffi

Run Tests

make test-all

Build for Release

make release

Clean Build Artifacts

make clean

Troubleshooting

FFI Generation Issues

Problem: flutter_rust_bridge_codegen: command not found

dart pub global activate flutter_rust_bridge_codegen

Problem: Rust compilation errors

cd rust_core && cargo check
# Fix errors shown

Build Issues

Problem: Flutter build fails

cd flutter_app
flutter clean
flutter pub get
flutter build

Problem: Rust build fails

cd rust_core
cargo clean
cargo build

Next Steps