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

Update dependency macos to v14 #38

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: push

jobs:
lint:
runs-on: macos-13
runs-on: macos-14
timeout-minutes: 10
name: Lint
steps:
Expand Down Expand Up @@ -35,7 +35,7 @@ jobs:
test:
needs: lint
timeout-minutes: 30
runs-on: macos-13
runs-on: macos-14
name: Test
steps:
- uses: maxim-lobanov/setup-xcode@v1
Expand Down
2 changes: 1 addition & 1 deletion Apps/iOSAppProd/iOSAppProd/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// iOSAppProd
//
// Created by maiyama18 on 2023/08/29
//
//
//

import SwiftUI
Expand Down
8 changes: 4 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ let targets: [PackageDescription.Target] = [
],
path: "Sources/Feature/PlayerFeature"
),

// UI module

.target(
Expand Down Expand Up @@ -301,11 +301,11 @@ let targets: [PackageDescription.Target] = [
.algorithms,
"Entity",
"RSSClient",
"ITunesClient"
"ITunesClient",
],
path: "Sources/Data/ShowSearchUseCase"
),

// Infra module

.target(
Expand Down Expand Up @@ -408,7 +408,7 @@ let targets: [PackageDescription.Target] = [
name: "DeepLink",
dependencies: [
.dependencies,
"Environment"
"Environment",
],
path: "Sources/Core/DeepLink"
),
Expand Down
4 changes: 2 additions & 2 deletions Sources/App/iOSApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import UIKit
final class AppDelegate: NSObject, UIApplicationDelegate {
@Dependency(\.logger[.app]) private var logger
@Dependency(\.duplicatedRecordsDeleteUseCase) private var duplicatedRecordsDeleteUseCase

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
do {
try AVAudioSession.sharedInstance().setCategory(.playback, mode: .default)
Expand All @@ -18,7 +18,7 @@ final class AppDelegate: NSObject, UIApplicationDelegate {
}
return true
}

func application(_ application: UIApplication, handleEventsForBackgroundURLSession identifier: String) async {
logger.notice("handleEventsForBackgroundURLSession")
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/App/iOSApp/iOSApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import SwiftUI

public struct IOSApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate

private let navigationState: NavigationState = .shared
private let soundFileState: SoundFileState = .shared
private let soundPlayerState: SoundPlayerState = .shared
private let persistentContainer: PersistentProvider = .cloud

@Dependency(\.logger[.app]) private var logger
@Dependency(\.duplicatedRecordsDeleteUseCase) private var duplicatedRecordsDeleteUseCase

public init() {}

public var body: some Scene {
Expand Down
24 changes: 12 additions & 12 deletions Sources/Core/Database/EpisodePlayingStateRecord+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,59 @@ import Dependencies

extension EpisodePlayingStateRecord {
struct RecordNotFound: Error {}

public static func withEpisodeID(_ episodeID: String) -> NSFetchRequest<EpisodePlayingStateRecord> {
let request = EpisodePlayingStateRecord.fetchRequest()
request.predicate = NSPredicate(format: "episode.id_ == %@", episodeID)
return request
}

@MainActor
public func startPlaying(atTime: TimeInterval) throws {
@Dependency(\.date.now) var now

guard let episode else { throw RecordNotFound() }
isCompleted = false
isPlaying = true
willFinishedAt = now.addingTimeInterval(episode.duration - atTime)
lastPausedTime = 0

try save()
}

@MainActor
public func pause(atTime: TimeInterval) throws {
isPlaying = false
willFinishedAt = nil
lastPausedTime = atTime

try save()
}

@MainActor
public func move(to time: TimeInterval) throws {
@Dependency(\.date.now) var now

guard let episode else { throw RecordNotFound() }
if isPlaying {
willFinishedAt = now.addingTimeInterval(episode.duration - time)
} else {
lastPausedTime = time
}

try save()
}

@MainActor
public func complete() throws {
isPlaying = false
isCompleted = true
willFinishedAt = nil
lastPausedTime = 0

try save()
}

private func save() throws {
guard let context = managedObjectContext else {
throw NSError(domain: "no context", code: 0)
Expand Down
14 changes: 7 additions & 7 deletions Sources/Core/Database/EpisodeRecord+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ extension EpisodeRecord {
request.predicate = NSPredicate(format: "id_ == %@", id)
return request
}

@MainActor
public static func followed() -> NSFetchRequest<EpisodeRecord> {
let request = EpisodeRecord.fetchRequest()
request.predicate = NSPredicate(format: "followed = %@", NSNumber(value: true))
request.sortDescriptors = [.init(keyPath: \EpisodeRecord.publishedAt_, ascending: false)]
return request
}

public static func withShowFeedURL(_ url: URL) -> NSFetchRequest<EpisodeRecord> {
let request = EpisodeRecord.fetchRequest()
request.predicate = NSPredicate(format: "show.feedURL_ == %@", url as CVarArg)
request.sortDescriptors = [.init(keyPath: \EpisodeRecord.publishedAt_, ascending: false)]
return request
}

public var id: String { id_ ?? "" }
public var title: String { title_ ?? "" }
public var soundURL: URL { soundURL_! }
public var publishedAt: Date { publishedAt_ ?? .now }

public convenience init(
context: NSManagedObjectContext = PersistentProvider.cloud.viewContext,
id: String,
Expand All @@ -41,7 +41,7 @@ extension EpisodeRecord {
publishedAt: Date
) {
self.init(context: context)

self.id_ = id
self.title_ = title
self.subtitle = subtitle
Expand Down Expand Up @@ -70,7 +70,7 @@ extension EpisodeRecord {
soundURL: URL(string: "https://example.com")!,
publishedAt: rssDateFormatter.date(from: "Tue, 03 Jan 2023 20:00:00 -0800")!
)

episode.show = ShowRecord(
context: context,
title: "Rebuild",
Expand All @@ -80,7 +80,7 @@ extension EpisodeRecord {
imageURL: URL(string: "https://cdn.rebuild.fm/images/icon1400.jpg")!,
linkURL: URL(string: "https://rebuild.fm")
)

return episode
}
}
22 changes: 11 additions & 11 deletions Sources/Core/Database/PersistentProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public final class PersistentProvider {
public static let cloud: PersistentProvider = .init(
persistentContainer: makePersistentCloudKitContainer(containerIdentifier: "iCloud.com.muijp.DropcastDev")
)

public static let inMemory: PersistentProvider = .init(
persistentContainer: {
let model = NSManagedObjectModel(contentsOf: Bundle.module.url(forResource: "Model", withExtension: "momd")!)!
Expand All @@ -17,37 +17,37 @@ public final class PersistentProvider {
return container
}()
)

private static func storeURL() -> URL {
let storeDirectory = NSPersistentCloudKitContainer.defaultDirectoryURL()
return storeDirectory.appendingPathComponent("Synced.sqlite")
}

private static func makePersistentCloudKitContainer(containerIdentifier: String) -> NSPersistentContainer {
@Dependency(\.logger[.database]) var logger

let model = NSManagedObjectModel(contentsOf: Bundle.module.url(forResource: "Model", withExtension: "momd")!)!
let container = NSPersistentCloudKitContainer(name: "Model", managedObjectModel: model)

let storeURL = Self.storeURL()
logger.notice("store url: \(storeURL, privacy: .public)")
let description = NSPersistentStoreDescription(url: storeURL)
description.cloudKitContainerOptions = NSPersistentCloudKitContainerOptions(containerIdentifier: containerIdentifier)
description.setOption(true as NSNumber, forKey: NSPersistentHistoryTrackingKey)
description.setOption(true as NSNumber, forKey: NSPersistentStoreRemoteChangeNotificationPostOptionKey)

container.persistentStoreDescriptions = [description]

container.viewContext.automaticallyMergesChangesFromParent = true

return container
}

public var viewContext: NSManagedObjectContext { persistentContainer.viewContext }
public var managedObjectModel: NSManagedObjectModel { persistentContainer.managedObjectModel }

private let persistentContainer: LockIsolated<NSPersistentContainer>

private init(persistentContainer: NSPersistentContainer) {
self.persistentContainer = LockIsolated(persistentContainer)
self.persistentContainer.withValue { container in
Expand Down
12 changes: 6 additions & 6 deletions Sources/Core/Database/ShowRecord+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ extension ShowRecord {
request.sortDescriptors = []
return request
}

@MainActor
public static func followed() -> NSFetchRequest<ShowRecord> {
let request = ShowRecord.fetchRequest()
request.predicate = NSPredicate(format: "followed = %@", NSNumber(value: true))
request.sortDescriptors = [.init(keyPath: \ShowRecord.title_, ascending: true)]
return request
}

@MainActor
public static func deleteAll(context: NSManagedObjectContext, feedURL: URL) throws {
for show in try context.fetch(Self.withFeedURL(feedURL)) {
Expand All @@ -34,15 +34,15 @@ extension ShowRecord {
throw error
}
}

public var title: String { title_! }
public var feedURL: URL { feedURL_! }
public var imageURL: URL { imageURL_! }
public var episodes: [EpisodeRecord] {
guard let episodes = episodes_ as? Set<EpisodeRecord> else { return [] }
return Array(episodes)
}

public convenience init(
context: NSManagedObjectContext = PersistentProvider.cloud.viewContext,
title: String,
Expand All @@ -53,15 +53,15 @@ extension ShowRecord {
linkURL: URL?
) {
self.init(context: context)

self.title_ = title
self.showDescription = description
self.author = author
self.feedURL_ = feedURL
self.imageURL_ = imageURL
self.linkURL = linkURL
}

@MainActor
public func toggleFollow() {
followed = !followed
Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/Entity/SearchedShow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ public struct SearchedShow: Sendable, Equatable {
public let imageURL: URL
public let title: String
public let author: String?

public init(feedURL: URL, imageURL: URL, title: String, author: String?) {
self.feedURL = feedURL
self.imageURL = imageURL
Expand Down
2 changes: 1 addition & 1 deletion Sources/Core/Extension/PreferenceKeys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import SwiftUI

public struct PlayerBannerHeightKey: PreferenceKey {
public static let defaultValue: Double = 0

public static func reduce(value: inout Double, nextValue: () -> Double) {
value = max(value, nextValue())
}
Expand Down
Loading