Bump deployment target to iOS 16, use URL.ParseStrategy

This commit is contained in:
Shadowfacts 2023-01-24 17:22:25 -05:00
parent 3990997e6e
commit d859552575
5 changed files with 16 additions and 31 deletions

View File

@ -6,7 +6,7 @@ import PackageDescription
let package = Package(
name: "Fervor",
platforms: [
.iOS(.v15),
.iOS(.v16),
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.

View File

@ -8,6 +8,16 @@
import Foundation
public struct Item: Decodable, Sendable {
private static let urlParseStrategy = URL.ParseStrategy()
.scheme(.defaultValue("https"))
.user(.optional)
.password(.optional)
.host(.required)
.port(.defaultValue(8080))
.path(.optional)
.query(.optional)
.fragment(.optional)
public let id: FervorID
public let feedID: FervorID
public let title: String?
@ -31,7 +41,8 @@ public struct Item: Decodable, Sendable {
self.createdAt = try container.decodeIfPresent(Date.self, forKey: .createdAt)
self.content = try container.decodeIfPresent(String.self, forKey: .content)
self.summary = try container.decodeIfPresent(String.self, forKey: .summary)
self.url = try container.decode(URL.self, forKey: .url)
let urlStr = try container.decode(String.self, forKey: .url)
self.url = try Self.urlParseStrategy.parse(urlStr)
self.serviceURL = try container.decodeIfPresent(URL.self, forKey: .serviceURL)
self.read = try container.decodeIfPresent(Bool.self, forKey: .read)
}

View File

@ -6,7 +6,7 @@ import PackageDescription
let package = Package(
name: "Persistence",
platforms: [
.iOS(.v15),
.iOS(.v16),
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.

View File

@ -904,7 +904,7 @@
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
@ -945,7 +945,7 @@
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",

View File

@ -24,8 +24,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
LocalData.migrateIfNecessary()
swizzleWKWebView()
Preferences.shared.objectWillChange
.debounce(for: .milliseconds(250), scheduler: RunLoop.main)
.sink { _ in
@ -133,30 +131,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
}
// this workaround is no longer necessary (in fact, it causes a stack overflow) post-iOS 15.4 because of:
// https://github.com/WebKit/WebKit/commit/1dbd34cf01d8b5aedcb8820b13cb6553ed60e8ed
@available(iOS, obsoleted: 15.4)
private func swizzleWKWebView() {
if #available(iOS 15.4, *) {
} else {
let selector = Selector(("_updateScrollViewBackground"))
var originalIMP: IMP?
let imp = imp_implementationWithBlock({ (self: WKWebView) in
if let originalIMP = originalIMP {
let original = unsafeBitCast(originalIMP, to: (@convention(c) (WKWebView, Selector) -> Void).self)
original(self, selector)
}
self.scrollView.indicatorStyle = .default
} as (@convention(block) (WKWebView) -> Void))
originalIMP = class_replaceMethod(WKWebView.self, selector, imp, "v@:")
if originalIMP == nil {
os_log(.error, "Missing originalIMP for -[WKWebView _updateScrollViewBackground], did WebKit change?")
}
}
}
@objc private func showPreferences() {
let existing = UIApplication.shared.connectedScenes.first {
$0.session.configuration.name == "prefs"