Skip to content

Commit

Permalink
Merge pull request #42 from bilaalrashid/bilaal/swift-6
Browse files Browse the repository at this point in the history
Support Swift 6
  • Loading branch information
bilaalrashid authored Oct 12, 2024
2 parents 13c2e9b + 669ed8c commit a02c105
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 22 deletions.
8 changes: 4 additions & 4 deletions ReadBeeb.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = Debug;
Expand Down Expand Up @@ -903,7 +903,7 @@
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = 1;
};
name = Release;
Expand All @@ -928,7 +928,7 @@
SUPPORTS_MACCATALYST = NO;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = 1;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ReadBeeb.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/ReadBeeb";
};
Expand All @@ -953,7 +953,7 @@
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SWIFT_EMIT_LOC_STRINGS = NO;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = 1;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ReadBeeb.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/ReadBeeb";
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"location" : "https://github.com/bilaalrashid/bbc-news-swift",
"state" : {
"branch" : "main",
"revision" : "2384a4837a85c96e65ab82907dfa77c53b0eec97"
"revision" : "9e6b9dfb2763eab0253176f5a2d889a09bce06d6"
}
},
{
Expand All @@ -24,17 +24,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/gh123man/LazyPager",
"state" : {
"revision" : "9dadeab5a66e7c4bff97b1e363f791b4ebfca1f6",
"version" : "1.0.6"
"revision" : "8de04797aa3c3bada70bb7bcecf040cf36ca3b56",
"version" : "1.1.0"
}
},
{
"identity" : "tldextractswift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/MarcoEidinger/TLDExtractSwift",
"state" : {
"revision" : "7c82b65eedcc5e309243a54268f167cf91755e84",
"version" : "2.3.11"
"revision" : "181c2e43e10b284719802b5be6a612ac48a0720e",
"version" : "2.3.12"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>ReadBeeb.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
<key>SWXMLHashPlayground (Playground) 1.xcscheme</key>
<dict>
Expand Down
2 changes: 1 addition & 1 deletion ReadBeeb/BbcMedia/BbcMedia.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct BbcMedia {
let session: URLSession

/// Creates a new network controller for fetching media items.
init() {
@MainActor init() {
let configuration = URLSessionConfiguration.default
configuration.httpAdditionalHeaders = [
// Pretend to be the BBC News app
Expand Down
7 changes: 6 additions & 1 deletion ReadBeeb/Components/Discovery/VideoPortraitStory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,12 @@ struct VideoPortraitStory: View {
}

let service = UserDefaults.standard.string(forKey: Constants.UserDefaultIdentifiers.service)
let api = BbcNews(service: Service(rawValue: service ?? "") ?? .english)
let api = BbcNews(
modelIdentifier: UIDevice.current.modelIdentifier,
systemName: UIDevice.current.systemName,
systemVersion: UIDevice.current.systemVersion,
service: Service(rawValue: service ?? "") ?? .english
)

let result = await api.fetch(url: url)

Expand Down
8 changes: 6 additions & 2 deletions ReadBeeb/Components/Reusable/VideoPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ struct VideoPlayer: UIViewControllerRepresentable {
try? audioSession.setCategory(.playback, mode: .moviePlayback)

NotificationCenter.default.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: self.player.currentItem, queue: .main) { _ in
self.onFinish?()
Task { @MainActor in
self.onFinish?()
}
}

return viewController
Expand All @@ -37,7 +39,9 @@ struct VideoPlayer: UIViewControllerRepresentable {
uiViewController.player = self.player

NotificationCenter.default.addObserver(forName: .AVPlayerItemDidPlayToEndTime, object: self.player.currentItem, queue: .main) { _ in
self.onFinish?()
Task { @MainActor in
self.onFinish?()
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion ReadBeeb/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation
import SwiftUI
import Kingfisher
@preconcurrency import Kingfisher

/// Global constants for the system.
enum Constants {
Expand Down
2 changes: 1 addition & 1 deletion ReadBeeb/Extensions/BbcNews/FDImage+Id.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation
import BbcNews

extension FDImage: Identifiable {
extension FDImage: @retroactive Identifiable {
/// A wrapper around `source.url` to conform `FDImage` to identifiable.
public var id: String {
return self.source.url
Expand Down
2 changes: 1 addition & 1 deletion ReadBeeb/Extensions/Logger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import OSLog

extension Logger {
/// The subsystem of the logger.
private static var subsystem = Constants.bundleIdentifier
private static let subsystem = Constants.bundleIdentifier

/// Logging related to networking
static let network = Logger(subsystem: Logger.subsystem, category: "network")
Expand Down
2 changes: 1 addition & 1 deletion ReadBeeb/Extensions/URL+Identifiable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

extension URL: Identifiable {
extension URL: @retroactive Identifiable {
/// A wrapper around `absoluteString` to conform `URL` to identifiable.
public var id: String {
return self.absoluteString
Expand Down
8 changes: 7 additions & 1 deletion ReadBeeb/ViewModels/DestinationDetailViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import Foundation
import BbcNews
import OSLog
import UIKit

extension DestinationDetailScreen {
/// The view model for the destination detail screen.
Expand Down Expand Up @@ -75,7 +76,12 @@ extension DestinationDetailScreen {
self.networkRequest = .loading

let service = UserDefaults.standard.string(forKey: Constants.UserDefaultIdentifiers.service)
let api = BbcNews(service: Service(rawValue: service ?? "") ?? .english)
let api = BbcNews(
modelIdentifier: UIDevice.current.modelIdentifier,
systemName: UIDevice.current.systemName,
systemVersion: UIDevice.current.systemVersion,
service: Service(rawValue: service ?? "") ?? .english
)

let result = await api.fetch(url: self.destination.url)

Expand Down
15 changes: 13 additions & 2 deletions ReadBeeb/ViewModels/GlobalViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import Foundation
import BbcNews
import OSLog
import UIKit

/// The global view model for the system.
@MainActor class GlobalViewModel: ObservableObject {
Expand Down Expand Up @@ -42,7 +43,12 @@ import OSLog

let postcode = UserDefaults.standard.string(forKey: Constants.UserDefaultIdentifiers.postcodeIdentifier)
let service = UserDefaults.standard.string(forKey: Constants.UserDefaultIdentifiers.service)
let api = BbcNews(service: Service(rawValue: service ?? "") ?? .english)
let api = BbcNews(
modelIdentifier: UIDevice.current.modelIdentifier,
systemName: UIDevice.current.systemName,
systemVersion: UIDevice.current.systemVersion,
service: Service(rawValue: service ?? "") ?? .english
)

let result = await api.fetchIndexDiscoveryPage(postcode: postcode)

Expand Down Expand Up @@ -113,7 +119,12 @@ import OSLog
var storyPromos = Set<FDStoryPromo>()

let service = UserDefaults.standard.string(forKey: Constants.UserDefaultIdentifiers.service)
let api = BbcNews(service: Service(rawValue: service ?? "") ?? .english)
let api = BbcNews(
modelIdentifier: UIDevice.current.modelIdentifier,
systemName: UIDevice.current.systemName,
systemVersion: UIDevice.current.systemVersion,
service: Service(rawValue: service ?? "") ?? .english
)

for url in urls {
let result = await api.fetch(url: url)
Expand Down
8 changes: 7 additions & 1 deletion ReadBeeb/ViewModels/MyNewsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import Foundation
import BbcNews
import OSLog
import UIKit

extension MyNewsScreen {
/// The view model for the My News screen.
Expand Down Expand Up @@ -42,7 +43,12 @@ extension MyNewsScreen {
let ids = selectedTopics.map { $0.id }

let service = UserDefaults.standard.string(forKey: Constants.UserDefaultIdentifiers.service)
let api = BbcNews(service: Service(rawValue: service ?? "") ?? .english)
let api = BbcNews(
modelIdentifier: UIDevice.current.modelIdentifier,
systemName: UIDevice.current.systemName,
systemVersion: UIDevice.current.systemVersion,
service: Service(rawValue: service ?? "") ?? .english
)

let result = await api.fetchTopicDiscoveryPages(for: ids)

Expand Down

0 comments on commit a02c105

Please sign in to comment.