Skip to content

Commit

Permalink
Apply Xcode 13 recommended settings and fix build.
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanw committed Sep 19, 2021
1 parent b5eabf9 commit 44c4b4d
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 31 deletions.
39 changes: 28 additions & 11 deletions App/URLs/ResourceURLProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ final class ResourceURLProtocol: URLProtocol {
@available(iOS 11.0, *)
extension ResourceURLProtocol: WKURLSchemeHandler {
func webView(_ webView: WKWebView, start task: WKURLSchemeTask) {
loadResource(url: task.request.url!, client: .webkit(task))
loadResource(url: task.request.url!, client: .webkit(.init(task)))
}

func webView(_ webView: WKWebView, stop task: WKURLSchemeTask) {
Expand Down Expand Up @@ -168,16 +168,27 @@ private struct Resource {

private enum URLClientWrapper {
case foundation(URLProtocolClient)
@available(iOS 11.0, *)
case webkit(WKURLSchemeTask)
case webkit(TaskAvailabilityWrapper)

struct TaskAvailabilityWrapper {
let _task: Any

@available(iOS 11.0, *)
var task: WKURLSchemeTask { _task as! WKURLSchemeTask }

@available(iOS 11.0, *)
init(_ task: WKURLSchemeTask) { _task = task }
}

func didFailWithError(_ error: Error, in urlProtocol: URLProtocol) {
switch self {
case .foundation(let client):
client.urlProtocol(urlProtocol, didFailWithError: error)

case .webkit(let task):
task.didFailWithError(error)
case .webkit(let wrapper):
if #available(iOS 11.0, *) {
wrapper.task.didFailWithError(error)
}
}
}

Expand All @@ -186,8 +197,10 @@ private enum URLClientWrapper {
case .foundation(let client):
client.urlProtocol(urlProtocol, didReceive: response, cacheStoragePolicy: .notAllowed)

case .webkit(let task):
task.didReceive(response)
case .webkit(let wrapper):
if #available(iOS 11.0, *) {
wrapper.task.didReceive(response)
}
}
}

Expand All @@ -196,8 +209,10 @@ private enum URLClientWrapper {
case .foundation(let client):
client.urlProtocol(urlProtocol, didLoad: data)

case .webkit(let task):
task.didReceive(data)
case .webkit(let wrapper):
if #available(iOS 11.0, *) {
wrapper.task.didReceive(data)
}
}
}

Expand All @@ -206,8 +221,10 @@ private enum URLClientWrapper {
case .foundation(let client):
client.urlProtocolDidFinishLoading(urlProtocol)

case .webkit(let task):
task.didFinish()
case .webkit(let wrapper):
if #available(iOS 11.0, *) {
wrapper.task.didFinish()
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
38 changes: 32 additions & 6 deletions Pods/Pods.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Pods/PullToRefresher.xcodeproj/project.pbxproj

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Xcode/Awful.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2177,7 +2177,7 @@
CLASSPREFIX = "";
LastSwiftMigration = 0710;
LastSwiftUpdateCheck = 1200;
LastUpgradeCheck = 1250;
LastUpgradeCheck = 1300;
ORGANIZATIONNAME = "Awful Contributors";
TargetAttributes = {
1C3A143219DFC5D10022C44C = {
Expand Down Expand Up @@ -2983,6 +2983,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = ../CopyMarkdown/App/App.entitlements;
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
Expand Down Expand Up @@ -3060,6 +3061,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = ../CopyMarkdown/App/App.entitlements;
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
Expand Down Expand Up @@ -3127,6 +3129,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = ../CopyMarkdown/Extension/Extension.entitlements;
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
Expand Down Expand Up @@ -3202,6 +3205,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_ENTITLEMENTS = ../CopyMarkdown/Extension/Extension.entitlements;
CODE_SIGN_IDENTITY = "-";
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
LastUpgradeVersion = "1300"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
LastUpgradeVersion = "1300"
wasCreatedForAppExtension = "YES"
version = "2.0">
<BuildAction
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
LastUpgradeVersion = "1300"
wasCreatedForAppExtension = "YES"
version = "2.0">
<BuildAction
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1250"
LastUpgradeVersion = "1300"
wasCreatedForAppExtension = "YES"
version = "2.0">
<BuildAction
Expand Down

0 comments on commit 44c4b4d

Please sign in to comment.