Skip to content

Ryu0118/swift-debug-todo

Repository files navigation

DebugTodo

A SwiftUI-based todo list library for debugging and development purposes with optional GitHub integration.

Usage

Basic Usage (Without GitHub Integration)

import SwiftUI
import DebugTodo

struct ContentView: View {
    var body: some View {
        NavigationStack {
            TodoListView(storage: UserDefaultsStorage())
        }
    }
}

With GitHub Integration

import SwiftUI
import DebugTodo

struct ContentView: View {
    @State private var service = GitHubService()

    var body: some View {
        NavigationStack {
            TodoListView(
                storage: UserDefaultsStorage(),
                service: service
            )
        }
    }
}

Setup: Tap the settings icon (gear) in the toolbar, then enter:

  • Personal Access Token (required scope: repo for private repos, public_repo for public repos only)
  • Owner and Repo name

Note: TodoListView uses SwiftUI's NavigationLink internally. Wrap it in NavigationStack if presenting as a root view or in a sheet

Storage Options

InMemory Storage (data lost on app termination):

TodoListView(storage: InMemoryStorage())

File Storage (JSON file persistence):

let fileURL = FileManager.default
    .urls(for: .documentDirectory, in: .userDomainMask)[0]
    .appendingPathComponent("todos.json")
TodoListView(storage: FileStorage(fileURL: fileURL))

UserDefaults Storage:

TodoListView(storage: UserDefaultsStorage())

// Custom key
TodoListView(storage: UserDefaultsStorage(
    userDefaults: .standard,
    key: "myCustomTodos"
))

Requirements

  • Swift: 6.2+
  • Xcode: 26.0+
  • Platforms:
    • iOS 17.0+
    • macOS 14.0+
    • visionOS 1.0+
    • Mac Catalyst 17.0+

Installation

Swift Package Manager

Add the following to your Package.swift:

dependencies: [
    .package(url: "https://github.com/yourusername/swift-debug-todo.git", from: "0.1.0")
]

Or add it through Xcode:

  1. File → Add Package Dependencies
  2. Enter the repository URL
  3. Select the version you want to use

Example App

See the Example/ directory for a complete sample app demonstrating all storage implementations and GitHub integration.

Advanced Configuration

Custom Keychain Configuration

struct ContentView: View {
    @State private var service: GitHubService = {
        let tokenStorage = KeychainTokenStorage(
            service: "com.myapp.github",
            key: "myAccessToken"
        )

        let repositorySettingsStorage = KeychainRepositorySettingsStorage(
            service: "com.myapp.github",
            ownerKey: "myOwner",
            repoKey: "myRepo",
            showConfirmationAlertKey: "myShowConfirmation"
        )

        return GitHubService(
            tokenStorage: tokenStorage,
            repositorySettingsStorage: repositorySettingsStorage
        )
    }()

    var body: some View {
        NavigationStack {
            TodoListView(
                storage: UserDefaultsStorage(),
                service: service
            )
        }
    }
}

Debug Logging

TodoListView(
    storage: UserDefaultsStorage(),
    service: service,
    logLevel: .debug  // Available: .trace, .debug, .info, .notice, .warning, .error, .critical
)

Custom Protocols

Implement these protocols for custom backends:

Storage Protocol:

public protocol Storage: Sendable {
    func save(_ items: [TodoItem]) async throws
    func load() async throws -> [TodoItem]
    func delete() async throws
}

GitHub Token Storage:

public protocol GitHubTokenStorage: Sendable {
    func saveToken(_ token: String) async throws
    func loadToken() async throws -> String?
    func deleteToken() async throws
}

GitHub Issue Creator:

public protocol GitHubIssueCreatorProtocol: Sendable {
    func createIssue(for item: TodoItem) async throws -> GitHubIssue?
    func updateIssueState(
        owner: String,
        repo: String,
        issueNumber: Int,
        state: String,
        stateReason: String?
    ) async throws -> GitHubIssue?
    func updateIssueContent(
        owner: String,
        repo: String,
        issueNumber: Int,
        title: String,
        body: String?
    ) async throws -> GitHubIssue?
}

About

Todo list for debugging, syncing with GitHub Issues

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •