Skip to content

OneBusAway/otpkit

Repository files navigation

OTPKit

Swift iOS SPM License Build

otpkit-showcase

Introduction

OpenTripPlanner library for iOS, written in Swift. OTPKit is a reusable library that powers trip planning in the OneBusAway iOS app and can be integrated into any iOS application.

  • Compatible with iOS 17+
  • Works with OpenTripPlanner 1.5.x and higher
  • Licensed under Apache 2.0
  • Provides networking, models, and APIs for building a complete trip planning experience

Quick Start

Installation

Add OTPKit to your iOS project using Swift Package Manager:

dependencies: [
    .package(url: "https://github.com/OneBusAway/OTPKit.git", from: "1.0.0")
]

SwiftUI Usage

import OTPKit

struct ContentView: View {
   var body: some View {
       // 1. Configure OTPKit with server URL and theme
       let config = OTPConfiguration(
           otpServerURL: URL(string: "https://your-otp-server.com")!,
           region: .userLocation(fallback: .automatic),
           themeConfiguration: OTPThemeConfiguration(primaryColor: .blue, secondaryColor: .gray)
       )

       // 2. Create API service for OpenTripPlanner
       let apiService = RestAPIService(baseURL: config.otpServerURL)

       VStack {
           // 3. Add complete trip planner to your app
           OTPView(otpConfig: config, apiService: apiService)
       }
   }
}

UIKit Usage

import OTPKit

let config = OTPConfiguration(
    otpServerURL: URL(string: "https://your-otp-server.com")!,
    region: .userLocation(fallback: .automatic)
)

let apiService = RestAPIService(baseURL: config.otpServerURL)
let tripPlannerView = OTPView(otpConfig: config, apiService: apiService)

// Embed in UIKit using UIHostingController
let hostingController = UIHostingController(rootView: tripPlannerView)
addChild(hostingController)
view.addSubview(hostingController.view)

SwiftLint

OTPKit uses SwiftLint to enforce consistent code style and Swift best practices. Install it locally using Homebrew:

brew install swiftlint

About the project

This project was developed as part of Google Summer of Code 2025, created by Manu Rajbhar with guidance from Aaron Brethorst.

You can read the full final report here: GSoC 2025 Final Report – OTPKit

License

Licensed under Apache 2.0. See LICENSE for more details.

Contributors

OTPKit was originally created as a Google Summer of Code project.

About

OpenTripPlanner library for iOS, written in Swift

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5

Languages