Skip to main content

Development Setup

This guide will help you set up a development environment to build and contribute to TablePro.

Prerequisites

Before you begin, ensure you have the following installed:

Required Software

SoftwareVersionPurpose
macOS13.5+ (Ventura)Target platform
Xcode15.0+Development IDE
GitLatestVersion control

Optional Tools

ToolPurpose
SwiftLintCode linting
SwiftFormatCode formatting
HomebrewPackage management

Getting Started

Step 1: Clone the Repository

git clone https://github.com/datlechin/tablepro.git
cd tablepro

Step 2: Install Development Tools

Install SwiftLint and SwiftFormat for code quality:
# Using Homebrew
brew install swiftlint swiftformat

Step 3: Open in Xcode

open TablePro.xcodeproj
Or open Xcode manually and select File > Open > navigate to TablePro.xcodeproj.

Step 4: Build and Run

  1. Select the TablePro scheme in Xcode
  2. Select My Mac as the destination
  3. Press Cmd+R to build and run
Xcode setup

Project Structure

tablepro
TablePro
Extensions
Resources
TableProTests
Libs
.swiftlint.yml
.swiftformat

Building

Development Build

For day-to-day development:
# Build for current architecture (Debug)
xcodebuild -project TablePro.xcodeproj -scheme TablePro -configuration Debug build -skipPackagePluginValidation

# Or use Xcode: Cmd+B

Release Build

For distribution-ready builds:
# Build for Apple Silicon
scripts/build-release.sh arm64

# Build for Intel
scripts/build-release.sh x86_64

# Build for both architectures
scripts/build-release.sh both
See Building for detailed build instructions.

Running Tests

# Run all tests
xcodebuild -project TablePro.xcodeproj -scheme TablePro test -skipPackagePluginValidation

# Run specific test class
xcodebuild -project TablePro.xcodeproj -scheme TablePro test -skipPackagePluginValidation \
    -only-testing:TableProTests/TestClassName

# Run specific test method
xcodebuild -project TablePro.xcodeproj -scheme TablePro test -skipPackagePluginValidation \
    -only-testing:TableProTests/TestClassName/testMethodName
Or in Xcode: Product > Test (Cmd+U).

Code Quality

SwiftLint

Run SwiftLint to check for code issues:
# Check for issues
swiftlint lint

# Auto-fix fixable issues
swiftlint --fix
SwiftLint runs automatically during Xcode builds.

SwiftFormat

Format code to match project style:
# Format all code
swiftformat .

# Check formatting without applying
swiftformat --lint .
Run SwiftFormat before committing to ensure consistent code style.

Configuration Files

.swiftlint.yml

SwiftLint rules and configuration:
  • Line length limits
  • Function complexity limits
  • Disabled rules
  • Custom rules

.swiftformat

SwiftFormat options:
  • Indentation style
  • Brace placement
  • Import ordering
  • Other formatting rules

Development Workflow

Making Changes

  1. Create a feature branch:
    git checkout -b feature/my-feature
    
  2. Make your changes
  3. Run linting:
    swiftlint lint
    swiftformat --lint .
    
  4. Run tests:
    xcodebuild -project TablePro.xcodeproj -scheme TablePro test -skipPackagePluginValidation
    
  5. Commit your changes:
    git add .
    git commit -m "Add my feature"
    
  6. Push and create a pull request:
    git push origin feature/my-feature
    

Debugging

Use Xcode’s debugging tools:
  1. Set breakpoints by clicking line numbers
  2. Use po in the debug console to print objects
  3. Use the Variables View to inspect state
  4. Use Console.app for system logs

Logging

TablePro uses OSLog for debugging:
import os

private static let logger = Logger(subsystem: "com.TablePro", category: "ComponentName")

// Usage
logger.debug("Connection established")
logger.info("Query executed in \(duration)s")
logger.error("Failed to connect: \(error.localizedDescription)")

Common Tasks

Adding a New View

  1. Create the SwiftUI view in appropriate Views/ subfolder
  2. Follow existing naming conventions (FeatureNameView.swift)
  3. Use @Observable or @StateObject for state management
  4. Add to navigation/routing as needed

Adding a Database Feature

  1. Implement in the appropriate driver (MySQLDriver.swift, etc.)
  2. Add to DatabaseDriver protocol if generic
  3. Add UI in relevant view components
  4. Add tests

Modifying Settings

  1. Add to appropriate settings struct in AppSettings.swift
  2. Update SettingsView to display the setting
  3. Use setting throughout the app via @AppStorage or settings manager

Troubleshooting

Build Fails

  1. Clean build folder: Cmd+Shift+K
  2. Delete derived data:
    rm -rf ~/Library/Developer/Xcode/DerivedData
    
  3. Close and reopen Xcode
  4. Check for Xcode updates

SwiftLint Errors

  1. Read the error message carefully
  2. Check .swiftlint.yml for rule configuration
  3. Fix the issue or disable the rule if appropriate
  4. Run swiftlint --fix for auto-fixable issues

Missing Libraries

If native libraries are missing:
  1. Check the Libs/ directory
  2. Ensure libmariadb_universal.a exists
  3. Run scripts/build-release.sh to prepare libraries

Next Steps