Skip to content

1.0.0

Choose a tag to compare

@Jezzatator Jezzatator released this 15 Mar 07:32
· 20 commits to main since this release
7f38671

πŸš‚ LocomoSwift 1.0.0

A major rewrite bringing GTFS Realtime support, modular imports, configurable data sources with API key authentication, and full DocC documentation.


✨ New Features

GTFS Realtime Support

  • Fetch trip updates, vehicle positions, and service alerts from GTFS-RT protobuf feeds
  • Actor-based RealtimeManager with automatic in-memory caching and configurable TTL per source
  • Protocol-based RealtimeDataSource for testability and future protocol support (SIRI SX)
  • Typed mappers: TripUpdateMapper, VehiclePositionMapper, ServiceAlertMapper
  • Rich models: RealtimeTripUpdate, RealtimeVehiclePosition, RealtimeServiceAlert, and related enums

DataSource Configuration Struct

  • Unified configuration for both GTFS Static and GTFS Realtime: URLs, refresh intervals, cache TTL
  • Built-in presets: .sncfTER, .sncfTGV, .sncfIntercites, .breizhgoTER, .tamMontpellier, .sbb
  • Fully custom sources via DataSource(identifier:displayName:...)
  • staticFeedNeedsRefresh(since:) for staleness checks
  • hasStaticFeed and availableRealtimeFeedTypes computed properties

API Key Authentication (APIAuthentication)

  • .queryParam(name:value:) β€” appends a query parameter to every request URL
  • .header(name:value:) β€” adds a custom HTTP header to every request
  • .none β€” default, no authentication
  • withAuthentication(_:) β€” create a copy of any preset with your own API key injected
  • Authentication applied automatically to both static downloads and realtime fetches

Modular Package (3 importable products)

  • LocomoSwiftGTFS β€” GTFS Static only (Feed, DataSource, models)
  • LocomoSwiftRT β€” GTFS Realtime only (RealtimeManager, mappers, models) β€” depends on LocomoSwiftGTFS
  • LocomoSwift β€” Umbrella that re-exports both via @_exported import

Feed + Realtime Integration

  • Feed(from: DataSource) β€” load static GTFS from a configured source
  • Feed.createRealtimeManager() β€” convenience to create a manager from a feed
  • Feed.applyRealtimeUpdates(...) β€” merge realtime data into a static feed
  • Feed.realtimeStatus(for:) β€” get delay/cancellation status for a trip

πŸ”§ Improvements

  • Swift 6.2 β€” Package upgraded to swift-tools-version: 6.2
  • Compiler warnings fixed β€” removed unnecessary #available checks, defer at end of scope, await on sync functions, deprecated init(serializedData:) β†’ init(serializedBytes:)
  • SOLID refactoring β€” DataSource, RealtimeError extracted into own files; FeedType renamed to RealtimeFeedType; preconditionFailure replaced with throws
  • Error handling β€” all error messages in English; LSError and RealtimeError conform to LocalizedError
  • URLSession.downloadTaskAsyncCompat β€” simplified to use native async/await API only (no legacy #available fallbacks)

πŸ“– Documentation

  • Comprehensive DocC catalog for both LocomoSwiftGTFS and LocomoSwiftRT
    • GettingStarted.md β€” installation, first feed, data access
    • DataSourceConfiguration.md β€” presets, custom sources, API key auth, refresh intervals
    • FetchingRealtimeData.md β€” manager creation, fetching, caching, error handling
  • Updated README β€” reflects 3-module architecture, all presets, auth examples, GTFS support tables
  • GitHub Actions CI β€” swift-tests.yaml workflow for automated testing

⚠️ Breaking Changes

  • Minimum Swift version: 6.2 (was 5.9)
  • Module split: import LocomoSwift still works (umbrella), but internal types moved to LocomoSwiftGTFS and LocomoSwiftRT
  • DataSource replaces enum-based configuration: sources are now structs, not enum cases
  • RealtimeManager.fetch* methods: no longer have a default source parameter β€” you must explicitly pass a DataSource
  • FeedType renamed to RealtimeFeedType

πŸ“¦ Dependencies

Dependency Version
ZIPFoundation 0.9.19
swift-protobuf 1.30.0

Full Changelog: 0.0.9...1.0.0