Skip to content

Commit d0de224

Browse files
authored
Fix iOS 13 warnings (#476)
1 parent abe4045 commit d0de224

File tree

12 files changed

+34
-57
lines changed

12 files changed

+34
-57
lines changed

Sources/LCP/Authentications/LCPDialogViewController.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,12 @@ final class LCPDialogViewController: UIViewController {
183183

184184
/// Makes sure the form contents is scrollable when the keyboard is visible.
185185
@objc func keyboardWillChangeFrame(_ note: Notification) {
186-
guard let window = UIApplication.shared.keyWindow, let scrollView = scrollView, let scrollViewSuperview = scrollView.superview, let info = note.userInfo else {
186+
guard
187+
let window = view.window,
188+
let scrollView = scrollView,
189+
let scrollViewSuperview = scrollView.superview,
190+
let info = note.userInfo
191+
else {
187192
return
188193
}
189194

Sources/Navigator/EPUB/EPUBSpreadView.swift

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -495,15 +495,7 @@ extension EPUBSpreadView: UIScrollViewDelegate {
495495
}
496496
}
497497

498-
extension EPUBSpreadView: WKUIDelegate {
499-
func webView(_ webView: WKWebView, shouldPreviewElement elementInfo: WKPreviewElementInfo) -> Bool {
500-
// Preview allowed only if the link is not internal
501-
guard let url = elementInfo.linkURL?.httpURL else {
502-
return true
503-
}
504-
return url.isRelative(to: viewModel.publicationBaseURL)
505-
}
506-
}
498+
extension EPUBSpreadView: WKUIDelegate {}
507499

508500
extension EPUBSpreadView: UIGestureRecognizerDelegate {
509501
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRequireFailureOf otherGestureRecognizer: UIGestureRecognizer) -> Bool {
@@ -517,19 +509,20 @@ private extension EPUBSpreadView {
517509
func updateActivityIndicator() {
518510
switch viewModel.theme {
519511
case .dark:
520-
createActivityIndicator(style: .white)
512+
createActivityIndicator(color: .white)
521513
default:
522-
createActivityIndicator(style: .gray)
514+
createActivityIndicator(color: .systemGray)
523515
}
524516
}
525517

526-
func createActivityIndicator(style: UIActivityIndicatorView.Style) {
527-
guard activityIndicatorView?.style != style else {
518+
func createActivityIndicator(color: UIColor) {
519+
guard activityIndicatorView?.color != color else {
528520
return
529521
}
530522

531523
activityIndicatorView?.removeFromSuperview()
532-
let view = UIActivityIndicatorView(style: style)
524+
let view = UIActivityIndicatorView(style: .medium)
525+
view.color = color
533526
view.translatesAutoresizingMaskIntoConstraints = false
534527
addSubview(view)
535528
view.centerXAnchor.constraint(equalTo: centerXAnchor).isActive = true

Sources/Navigator/EditingAction.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public struct EditingAction: Hashable {
3131
/// Search Web.
3232
public static let lookup = EditingAction(kind: .native(["lookup", "_lookup:", "define:", "_define:"]))
3333

34-
@available(*, deprecated, message: "lookup and define were merged", renamed: "lookup")
34+
@available(*, unavailable, message: "lookup and define were merged", renamed: "lookup")
3535
public static let define = lookup
3636

3737
/// Translate the text selection.

Sources/Navigator/TTS/AVTTSEngine.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class AVTTSEngine: NSObject, TTSEngine, AVSpeechSynthesizerDelegate, Logg
4747
synthesizer.delegate = self
4848
}
4949

50-
@available(*, deprecated, message: "The audio session is now configured through the `PublicationSpeechSynthesizer`")
50+
@available(*, unavailable, message: "The audio session is now configured through the `PublicationSpeechSynthesizer`")
5151
public convenience init(
5252
audioSessionConfig: AudioSession.Configuration? = nil,
5353
delegate: AVTTSEngineDelegate? = nil

Sources/Navigator/Toolkit/Extensions/UIView.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ extension UIView {
1818
/// We use that instead of pinning the content directly to the safe area layout guides to avoid
1919
/// the view shifting when the status bar is toggled.
2020
var notchAreaInsets: UIEdgeInsets {
21-
var windowSafeAreaInsets = window?.safeAreaInsets ?? safeAreaInsets
21+
guard let window = window else {
22+
return safeAreaInsets
23+
}
24+
25+
var windowSafeAreaInsets = window.safeAreaInsets
2226

2327
// Trick to ignore the status bar on devices without notches (pre iPhone X).
2428
// Notch height is usually at least 44pts tall.
25-
let statusBarSize = UIApplication.shared.statusBarFrame.size
29+
let statusBarSize = window.windowScene?.statusBarManager?.statusBarFrame.size ?? .zero
2630
// The frame is in the coordinate space of the window, so it might be swapped in landscape.
2731
let statusBarHeight = min(statusBarSize.width, statusBarSize.height)
2832
if statusBarHeight < 44, windowSafeAreaInsets.top == statusBarHeight {

Sources/Shared/Publication/Link.swift

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public struct Link: JSONEquatable, Hashable, Sendable {
206206

207207
// MARK: Copy
208208

209-
@available(*, deprecated, message: "Make a mutable copy of the struct instead")
209+
@available(*, unavailable, message: "Make a mutable copy of the struct instead")
210210
/// Makes a copy of the `Link`, after modifying some of its properties.
211211
public func copy(
212212
href: String? = nil,
@@ -223,21 +223,7 @@ public struct Link: JSONEquatable, Hashable, Sendable {
223223
alternates: [Link]? = nil,
224224
children: [Link]? = nil
225225
) -> Link {
226-
Link(
227-
href: href ?? self.href,
228-
mediaType: mediaType ?? self.mediaType,
229-
templated: templated ?? self.templated,
230-
title: title ?? self.title,
231-
rels: rels ?? self.rels,
232-
properties: properties ?? self.properties,
233-
height: height ?? self.height,
234-
width: width ?? self.width,
235-
bitrate: bitrate ?? self.bitrate,
236-
duration: duration ?? self.duration,
237-
languages: languages ?? self.languages,
238-
alternates: alternates ?? self.alternates,
239-
children: children ?? self.children
240-
)
226+
fatalError()
241227
}
242228

243229
/// Merges in the given additional other `properties`.
@@ -246,11 +232,9 @@ public struct Link: JSONEquatable, Hashable, Sendable {
246232
}
247233

248234
/// Makes a copy of this `Link` after merging in the given additional other `properties`.
249-
@available(*, deprecated, message: "Use `addProperties` on a mutable copy")
235+
@available(*, unavailable, message: "Use `addProperties` on a mutable copy")
250236
public func addingProperties(_ properties: [String: Any]) -> Link {
251-
var copy = self
252-
copy.addProperties(properties)
253-
return copy
237+
fatalError()
254238
}
255239
}
256240

Sources/Shared/Publication/Manifest.swift

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ public struct Manifest: JSONEquatable, Hashable, Sendable {
186186
}
187187

188188
/// Makes a copy of the `Manifest`, after modifying some of its properties.
189-
@available(*, deprecated, message: "Make a mutable copy of the struct instead")
189+
@available(*, unavailable, message: "Make a mutable copy of the struct instead")
190190
public func copy(
191191
context: [String]? = nil,
192192
metadata: Metadata? = nil,
@@ -196,14 +196,6 @@ public struct Manifest: JSONEquatable, Hashable, Sendable {
196196
tableOfContents: [Link]? = nil,
197197
subcollections: [String: [PublicationCollection]]? = nil
198198
) -> Manifest {
199-
Manifest(
200-
context: context ?? self.context,
201-
metadata: metadata ?? self.metadata,
202-
links: links ?? self.links,
203-
readingOrder: readingOrder ?? self.readingOrder,
204-
resources: resources ?? self.resources,
205-
tableOfContents: tableOfContents ?? self.tableOfContents,
206-
subcollections: subcollections ?? self.subcollections
207-
)
199+
fatalError()
208200
}
209201
}

Sources/Shared/Publication/Properties.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public struct Properties: Hashable, Loggable, WarningLogger, Sendable {
5050
}
5151

5252
/// Makes a copy of this `Properties` after merging in the given additional other `properties`.
53-
@available(*, deprecated, message: "Use `add` on a mutable copy")
53+
@available(*, unavailable, message: "Use `add` on a mutable copy")
5454
public func adding(_ properties: JSONDictionary.Wrapped) -> Properties {
5555
var copy = self
5656
copy.add(properties)

Sources/Shared/Publication/Publication.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,7 @@ public class Publication: Closeable, Loggable {
225225
public init(
226226
manifest: Manifest,
227227
container: Container,
228-
servicesBuilder: PublicationServicesBuilder = .init(),
229-
setupPublication: ((Publication) -> Void)? = nil
228+
servicesBuilder: PublicationServicesBuilder = .init()
230229
) {
231230
self.manifest = manifest
232231
self.container = container

Sources/Shared/Toolkit/Data/Resource/Resource.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ public extension Resource {
2424
@available(*, unavailable, message: "Use the async variant")
2525
var length: ResourceResult<UInt64> { fatalError() }
2626

27-
@available(*, deprecated, renamed: "sourceURL")
27+
@available(*, unavailable, renamed: "sourceURL")
2828
var file: FileURL? { fatalError() }
2929

3030
@available(*, unavailable, message: "Use the async variant")
3131
func read(range: Range<UInt64>?) -> ResourceResult<Data> { fatalError() }
3232

33-
@available(*, deprecated, message: "Use the async variant")
33+
@available(*, unavailable, message: "Use the async variant")
3434
func stream(range: Range<UInt64>?, consume: @escaping (Data) -> Void, completion: @escaping (ReadResult<Void>) -> Void) -> Cancellable {
3535
fatalError()
3636
}

Sources/Shared/Toolkit/Media/AudioSession.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import AVFoundation
88
import Foundation
99
import UIKit
1010

11-
@available(*, deprecated, message: "Use `AudioSession` instead")
11+
@available(*, unavailable, message: "Use `AudioSession` instead")
1212
public typealias _AudioSession = AudioSession
13-
@available(*, deprecated, message: "Use `AudioSessionUser` instead")
13+
@available(*, unavailable, message: "Use `AudioSessionUser` instead")
1414
public typealias _AudioSessionUser = AudioSessionUser
1515

1616
/// An user of the `AudioSession`, for example a media player object.

Sources/Shared/Toolkit/Media/NowPlayingInfo.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import Foundation
88
import MediaPlayer
99
import UIKit
1010

11-
@available(*, deprecated, message: "Use `NowPlayingInfo` instead")
11+
@available(*, unavailable, message: "Use `NowPlayingInfo` instead")
1212
public typealias _NowPlayingInfo = NowPlayingInfo
1313

1414
/// Manages the Now Playing media item displayed on the lock screen.

0 commit comments

Comments
 (0)