Skip to content

Extract TraverseCore Swift package shared between ios-swift and macos-swift #58

Description

@enricopiovesan

Summary

The iOS and macOS SwiftUI clients share identical HTTP + SSE client code and the AppStateViewModel. Rather than duplicating, extract a `TraverseCore` Swift package that both app targets import as a local dependency.

Depends on

Issues #44 (ios-swift) and #45 (macos-swift) — this issue should be implemented as part of or before #44/#45, not after.

Blocked on

Same as #44/#45: Traverse #525#527

Package contents

```
apps/traverse-starter/TraverseCore/
Package.swift
Sources/TraverseCore/
TraverseClient.swift # URLSession HTTP + SSE
AppStateViewModel.swift # ObservableObject — subscribes to SSE
TraverseOutput.swift # Output type + parsing
TraverseCommand.swift # Command dispatch
ServerDiscovery.swift # .traverse/server.json reader (macOS only via conditional compile)
Tests/TraverseCoreTests/
TraverseClientTests.swift
AppStateViewModelTests.swift
TraverseOutputTests.swift
```

Definition of Done

  • `TraverseCore` Swift package created with `Package.swift` (Swift 6, iOS 17+ / macOS 14+)
  • `TraverseClient`: URLSession HTTP + SSE streaming (EventSource-style via `URLSessionDataDelegate`)
  • `AppStateViewModel`: `@MainActor ObservableObject`, `@Published currentState`, `@Published output`
  • `ServerDiscovery`: reads `.traverse/server.json` on macOS (`#if os(macOS)`); returns nil on iOS
  • Unit tests cover: client request construction, SSE event parsing, view model state transitions
  • ios-swift and macos-swift both import `TraverseCore` as a local Swift package
  • No UIKit or AppKit imports in `TraverseCore` — platform-neutral

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions