Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More fixes #780

Merged
merged 7 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/obakittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ on:

jobs:
build:
runs-on: macos-14
runs-on: macos-15

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: actions/cache@v2
- uses: actions/cache@v4
with:
path: .build
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
restore-keys: |
${{ runner.os }}-spm-

- name: Switch Xcode 15
run: sudo xcode-select -switch /Applications/Xcode_15.4.app
run: sudo xcode-select -switch /Applications/Xcode_16.1.app

- name: Install xcodegen
run: brew install xcodegen
Expand All @@ -33,7 +33,7 @@ jobs:
- name: Build OneBusAway
run: xcodebuild clean build-for-testing
-scheme 'App'
-destination 'platform=iOS Simulator,name=iPhone 15'
-destination 'platform=iOS Simulator,name=iPhone 16'
-quiet

# Unit Test
Expand All @@ -42,7 +42,7 @@ jobs:
-only-testing:OBAKitTests
-project 'OBAKit.xcodeproj'
-scheme 'App'
-destination 'platform=iOS Simulator,name=iPhone 15'
-destination 'platform=iOS Simulator,name=iPhone 16'
-resultBundlePath OBAKitTests.xcresult
-quiet

Expand Down
4 changes: 2 additions & 2 deletions OBAKit/Bookmarks/BookmarksViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ public class BookmarksViewController: UIViewController,
let sortMenu = UIMenu(title: Strings.sort, options: .displayInline, children: [groupSortAction, distanceSortAction])
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "MORE", image: UIImage(systemName: "arrow.up.arrow.down.circle"), menu: sortMenu)
}

// MARK: Refresh Widget
func reloadWidget() {
print("Reloading the widget")
WidgetCenter.shared.reloadTimelines(ofKind: "OBAWidget")
}

// MARK: - Refresh Control

@objc private func refreshControlPulled() {
Expand Down
7 changes: 4 additions & 3 deletions OBAKit/Bookmarks/TripBookmarkCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ final class TripBookmarkTableCell: OBAListViewCell {
])

// MARK: - UI Builders
private class func buildLabel(textStyle: UIFont.TextStyle) -> UILabel {

private static func buildLabel(textStyle: UIFont.TextStyle) -> UILabel {
let label = UILabel.obaLabel(font: .preferredFont(forTextStyle: textStyle))
label.setContentCompressionResistancePriority(.required, for: .vertical)
label.setCompressionResistance(horizontal: .required, vertical: .required)
Expand All @@ -141,9 +142,9 @@ final class TripBookmarkTableCell: OBAListViewCell {

isAccessibilityElement = true
accessibilityTraits = [.button, .updatesFrequently]

let sizeTraits: [UITrait] = [UITraitVerticalSizeClass.self, UITraitHorizontalSizeClass.self]
registerForTraitChanges(sizeTraits) { (self: Self, previousTraitCollection: UITraitCollection) in
registerForTraitChanges(sizeTraits) { (self: Self, _) in
self.layoutView()
}
}
Expand Down
6 changes: 3 additions & 3 deletions OBAKit/DeepLinks/AppLinksRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class AppLinksRouter: NSObject {
public init?(application: Application) {
self.application = application
}

/// The base URL for all operations in this object.
private var baseURL: URL? {
application.regionsService.currentRegion?.sidecarBaseURL
Expand All @@ -33,7 +33,7 @@ public class AppLinksRouter: NSObject {
/// - region: The region in which the link will exist.
public func url(for stop: Stop, region: Region) -> URL? {
guard let baseURL else { return nil }

guard var components = URLComponents(url: baseURL, resolvingAgainstBaseURL: false) else { return nil }
components.path = String(format: "/regions/%d/stops/%@", region.regionIdentifier, stop.id)

Expand All @@ -49,7 +49,7 @@ public class AppLinksRouter: NSObject {
/// - region: The region in which the `ArrivalDeparture` exists.
public func encode(arrivalDeparture: ArrivalDeparture, region: Region) -> URL? {
guard let baseURL else { return nil }

var components = URLComponents(url: baseURL, resolvingAgainstBaseURL: false)!
components.path = String(format: deepLinkPathFormat, region.regionIdentifier, arrivalDeparture.stopID)
components.queryItems = [
Expand Down
2 changes: 1 addition & 1 deletion OBAKit/Donations/StripeExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#if canImport(Stripe)
import StripePaymentSheet

extension PaymentSheetResult: Equatable {
extension PaymentSheetResult: @retroactive Equatable {
public static func == (lhs: PaymentSheetResult, rhs: PaymentSheetResult) -> Bool {
switch (lhs, rhs) {
case (.completed, .completed), (.canceled, .canceled):
Expand Down
10 changes: 5 additions & 5 deletions OBAKit/Extensions/ModelExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import OBAKitCore

// MARK: - Bookmark/MKAnnotation

extension Bookmark: MKAnnotation {
extension Bookmark: @retroactive MKAnnotation {
public var coordinate: CLLocationCoordinate2D {
stop.coordinate
}
Expand All @@ -25,7 +25,7 @@ extension Bookmark: MKAnnotation {

// MARK: - Region/MKAnnotation

extension Region: MKAnnotation {
extension Region: @retroactive MKAnnotation {
public var coordinate: CLLocationCoordinate2D {
centerCoordinate
}
Expand All @@ -41,7 +41,7 @@ extension Region: MKAnnotation {
/// Includes additional methods for rendering extra data directly onto the map.
///
/// - Note: See `StopAnnotationView`for more details.
extension Stop: MKAnnotation {
extension Stop: @retroactive MKAnnotation {
public var coordinate: CLLocationCoordinate2D {
location.coordinate
}
Expand All @@ -64,7 +64,7 @@ extension Stop: MKAnnotation {
// MARK: - TripStatus/MKAnnotation

/// Adds conformance to `MKAnnotation` to `TripStatus`.
extension TripStatus: MKAnnotation {
extension TripStatus: @retroactive MKAnnotation {

public var coordinate: CLLocationCoordinate2D {
lastKnownLocation?.coordinate ?? CLLocationCoordinate2D(latitude: 0, longitude: 0)
Expand All @@ -85,7 +85,7 @@ extension TripStatus: MKAnnotation {
/// Adds conformance to `MKAnnotation` to `TripStopTime`.
///
/// - Note: See `MinimalStopAnnotationView`for more details.
extension TripStopTime: MKAnnotation {
extension TripStopTime: @retroactive MKAnnotation {
public var coordinate: CLLocationCoordinate2D {
stop.location.coordinate
}
Expand Down
6 changes: 2 additions & 4 deletions OBAKit/Mapping/MapViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -629,10 +629,8 @@ class MapViewController: UIViewController,
}
else {
promptUserOnRegionMismatch = false
if
let regionMismatchBulletin = RegionMismatchBulletin(application: application),
let uiApp = application.delegate?.uiApplication
{
if let regionMismatchBulletin = RegionMismatchBulletin(application: application),
let uiApp = application.delegate?.uiApplication {
self.regionMismatchBulletin = regionMismatchBulletin
self.regionMismatchBulletin?.show(in: uiApp)
}
Expand Down
2 changes: 1 addition & 1 deletion OBAKit/Mapping/PulsingAnnotationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class PulsingAnnotationView: MKAnnotationView {
layer.anchorPoint = CGPoint(x: 0.5, y: 0.5)
calloutOffset = CGPoint(x: 0, y: 4)
self.bounds = bounds

registerForTraitChanges([UITraitUserInterfaceStyle.self]) { (self: Self, previousTraitCollection: UITraitCollection) in
if self.traitCollection.userInterfaceStyle != previousTraitCollection.userInterfaceStyle {
self.rebuildLayers()
Expand Down
4 changes: 2 additions & 2 deletions OBAKit/Mapping/StopAnnotationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class StopAnnotationView: MKAnnotationView {
updateAccessibility()

NotificationCenter.default.addObserver(self, selector: #selector(voiceoverStatusDidChange), name: UIAccessibility.voiceOverStatusDidChangeNotification, object: nil)

registerForTraitChanges([UITraitUserInterfaceStyle.self]) { (self: Self, previousTraitCollection: UITraitCollection) in
if self.traitCollection.userInterfaceStyle != previousTraitCollection.userInterfaceStyle {
self.rebuildIcon()
Expand Down Expand Up @@ -174,7 +174,7 @@ class StopAnnotationView: MKAnnotationView {
// we should skip the callout and push directly to the annotation's destination view.
canShowCallout = !UIAccessibility.isVoiceOverRunning
}

private func rebuildIcon() {
guard
let stop = annotation as? Stop,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import OBAKitCore

extension DataMigrationError: LocalizedError {
extension DataMigrationError: @retroactive LocalizedError {
public var errorDescription: String? {
switch self {
case .invalidAPIService(let explanation):
Expand All @@ -22,7 +22,7 @@ extension DataMigrationError: LocalizedError {
}
}

extension DataMigrationBookmarkError: LocalizedError {
extension DataMigrationBookmarkError: @retroactive LocalizedError {
public var errorDescription: String? {
switch self {
case .noActiveTrips:
Expand Down
2 changes: 1 addition & 1 deletion OBAKit/Orchestration/Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public class Application: CoreApplication, PushServiceDelegate {
/// Handles all deep-linking into the app.
@objc public private(set) lazy var appLinksRouter: AppLinksRouter? = {
let router = AppLinksRouter(application: self)

router?.showStopHandler = { [weak self] stop in
guard
let self = self,
Expand Down
2 changes: 1 addition & 1 deletion OBAKit/Reporting/StopProblemViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import OBAKitCore
// This seems...busted. I can't figure out when this
// initializer will actually be called, though. Do I even
// really need it?
extension StopProblemCode: InputTypeInitiable {
extension StopProblemCode: @retroactive InputTypeInitiable {
public init?(string stringValue: String) {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion OBAKit/Reporting/VehicleProblemViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import OBAKitCore
// This seems...busted. I can't figure out when this
// initializer will actually be called, though. Do I even
// really need it?
extension TripProblemCode: InputTypeInitiable {
extension TripProblemCode: @retroactive InputTypeInitiable {
public init?(string stringValue: String) {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion OBAKit/Stops/NearbyStopsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class NearbyStopsViewController: UIViewController,
directions[stop.direction] = list
}

let tapHandler = { [unowned self] (vm: StopViewModel) -> Void in
let tapHandler = { [unowned self] (vm: StopViewModel) in
self.application.viewRouter.navigateTo(stopID: vm.stopID, from: self)
}

Expand Down
4 changes: 2 additions & 2 deletions OBAKit/Stops/StopHeaderController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ class StopHeaderView: UIView {
])

addGestureRecognizer(toggleRouteDetailsGestureRecognizer)

let sizeTraits: [UITrait] = [UITraitVerticalSizeClass.self, UITraitHorizontalSizeClass.self]
registerForTraitChanges(sizeTraits) { (self: Self, previousTraitCollection: UITraitCollection) in
registerForTraitChanges(sizeTraits) { (self: Self, _) in
self.configureView()
}
}
Expand Down
4 changes: 2 additions & 2 deletions OBAKit/Stops/WalkTimeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ class WalkTimeView: UIView {
])

NotificationCenter.default.addObserver(self, selector: #selector(deviceOrientationDidChange), name: UIDevice.orientationDidChangeNotification, object: nil)

let sizeTraits: [UITrait] = [UITraitVerticalSizeClass.self, UITraitHorizontalSizeClass.self]
registerForTraitChanges(sizeTraits) { (self: Self, previousTraitCollection: UITraitCollection) in
registerForTraitChanges(sizeTraits) { (self: Self, _) in
self.setNeedsDisplay()
}
}
Expand Down
4 changes: 2 additions & 2 deletions OBAKit/Trip/TripStopListItem.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ final class TripStopCell: OBAListViewCell {
])

isAccessibilityElement = true
registerForTraitChanges([UITraitPreferredContentSizeCategory.self]) { (self: Self, previousTraitCollection: UITraitCollection) in

registerForTraitChanges([UITraitPreferredContentSizeCategory.self]) { (self: Self, _) in
self.layoutAccessibility()
}
}
Expand Down
8 changes: 4 additions & 4 deletions OBAKit/Trip/TripViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class TripViewController: UIViewController,
self.tripConvertible = tripConvertible

super.init(nibName: nil, bundle: nil)

registerTraitChangeCallback()
}

Expand All @@ -39,7 +39,7 @@ class TripViewController: UIViewController,
self.tripConvertible = TripConvertible(arrivalDeparture: arrivalDeparture)

super.init(nibName: nil, bundle: nil)

registerTraitChangeCallback()
}

Expand All @@ -50,10 +50,10 @@ class TripViewController: UIViewController,
deinit {
enableIdleTimer()
}

private func registerTraitChangeCallback() {
let sizeTraits: [UITrait] = [UITraitVerticalSizeClass.self, UITraitHorizontalSizeClass.self, UITraitPreferredContentSizeCategory.self]
registerForTraitChanges(sizeTraits) { (self: Self, previousTraitCollection: UITraitCollection) in
registerForTraitChanges(sizeTraits) { (self: Self, _) in
self.updateTitleView()
}
}
Expand Down
1 change: 1 addition & 0 deletions OBAKit/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ targets:
postBuildScripts:
- path: "../scripts/swiftlint.sh"
name: Swiftlint
basedOnDependencyAnalysis: false
scheme:
gatherCoverageData: true
info:
Expand Down
3 changes: 2 additions & 1 deletion OBAKitCore/Extensions/CoreLocationExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import CoreGraphics
import CoreLocation
import MapKit

extension CLAuthorizationStatus: LosslessStringConvertible {
extension CLAuthorizationStatus: @retroactive CustomStringConvertible {}
extension CLAuthorizationStatus: @retroactive LosslessStringConvertible {
public init?(_ description: String) { nil }

public var description: String {
Expand Down
2 changes: 1 addition & 1 deletion OBAKitCore/Models/Region.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class Region: NSObject, Identifiable, Codable {

/// The base URL for making OBA REST API requests.
public let OBABaseURL: URL

/// The base URL for sidecar server (i.e. OneBusAway.co/Obaco) REST API requests
public let sidecarBaseURL: URL?

Expand Down
5 changes: 1 addition & 4 deletions OBAKitCore/Models/UserData/UserDataStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -563,10 +563,7 @@ public class UserDefaultsStore: NSObject, UserDataStore, StopPreferencesStore {
// MARK: - Private Helpers

private func upsert(bookmark: Bookmark) {
if
let existing = findBookmark(id: bookmark.id),
let index = bookmarks.firstIndex(of: existing)
{
if let existing = findBookmark(id: bookmark.id), let index = bookmarks.firstIndex(of: existing) {
bookmarks.remove(at: index)
bookmarks.insert(bookmark, at: index)
}
Expand Down
2 changes: 1 addition & 1 deletion OBAKitCore/Network/ObacoAPIService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public protocol ObacoServiceDelegate: NSObjectProtocol {
/// API service client for the Obaco (`alerts.onebusaway.org`) service.
///
/// Obaco provides services like weather, trip status, and alarms to the iOS app.
public actor ObacoAPIService: APIService {
public actor ObacoAPIService: @preconcurrency APIService {
public let configuration: APIServiceConfiguration
public nonisolated let dataLoader: URLDataLoader

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ extension RESTAPIService {

do {
let (data, _) = try await self.getData(for: url)
let message = try TransitRealtime_FeedMessage(serializedData: data)
let message = try TransitRealtime_FeedMessage(serializedBytes: data)
return message.entity
.filter(isQualifiedAlert)
.compactMap {
Expand Down
2 changes: 1 addition & 1 deletion OBAKitCore/Network/RESTAPIService/RESTAPIService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation
import os.log

/// Makes API calls to the OBA REST service and converts the server's responses into model objects.
public actor RESTAPIService: APIService {
public actor RESTAPIService: @preconcurrency APIService {
public let configuration: APIServiceConfiguration
public nonisolated let dataLoader: URLDataLoader

Expand Down
Loading
Loading