Skip to content

Commit 9b28750

Browse files
committed
Linter cleanup
Check warning on line 16 in Package.swift @github-actions github-actions / lint Package.swift#L16 Trailing Comma Violation: Collection literals should not have trailing commas. (trailing_comma) Check warning on line 26 in Package.swift @github-actions github-actions / lint Package.swift#L26 Trailing Comma Violation: Collection literals should not have trailing commas. (trailing_comma) Check warning on line 6 in Tests/GameKitUITests/XCTestManifests.swift @github-actions github-actions / lint Tests/GameKitUITests/XCTestManifests.swift#L6 Trailing Comma Violation: Collection literals should not have trailing commas. (trailing_comma) Check warning on line 13 in Tests/GameKitUITests/GameKitUITests.swift @github-actions github-actions / lint Tests/GameKitUITests/GameKitUITests.swift#L13 Trailing Comma Violation: Collection literals should not have trailing commas. (trailing_comma) Check warning on line 35 in Sources/GameKitUI/GKAuthenticationView.swift @github-actions github-actions / lint Sources/GameKitUI/GKAuthenticationView.swift#L35 Line Length Violation: Line should be 120 characters or less: currently 141 characters (line_length) Check warning on line 46 in Sources/GameKitUI/GKAuthenticationView.swift @github-actions github-actions / lint Sources/GameKitUI/GKAuthenticationView.swift#L46 Line Length Violation: Line should be 120 characters or less: currently 161 characters (line_length) Check warning on line 82 in Sources/GameKitUI/GKAuthenticationView.swift @github-actions github-actions / lint Sources/GameKitUI/GKAuthenticationView.swift#L82 Notification Center Detachment Violation: An object should only remove itself as an observer in `deinit`. (notification_center_detachment)
1 parent 18df7d6 commit 9b28750

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

Package.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ let package = Package(
1313
products: [
1414
.library(
1515
name: "GameKitUI",
16-
targets: ["GameKitUI"]),
16+
targets: ["GameKitUI"])
1717
],
1818
dependencies: [
1919
],
@@ -23,6 +23,6 @@ let package = Package(
2323
dependencies: []),
2424
.testTarget(
2525
name: "GameKitUITests",
26-
dependencies: ["GameKitUI"]),
26+
dependencies: ["GameKitUI"])
2727
]
2828
)

Sources/GameKitUI/GKAuthenticationView.swift

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ public struct GKAuthenticationView: UIViewControllerRepresentable {
3232
public let failed: ((Error) -> Void)
3333
public let authenticated: ((String) -> Void)
3434

35-
public func makeUIViewController(context: UIViewControllerRepresentableContext<GKAuthenticationView>) -> GKAuthenticationViewController {
35+
public func makeUIViewController(
36+
context: UIViewControllerRepresentableContext<GKAuthenticationView>) -> GKAuthenticationViewController {
3637
let authenticationViewController = GKAuthenticationViewController { (state) in
3738
self.state(state)
3839
} failed: { (error) in
@@ -43,7 +44,9 @@ public struct GKAuthenticationView: UIViewControllerRepresentable {
4344
return authenticationViewController
4445
}
4546

46-
public func updateUIViewController(_ uiViewController: GKAuthenticationViewController, context: UIViewControllerRepresentableContext<GKAuthenticationView>) {
47+
public func updateUIViewController(
48+
_ uiViewController: GKAuthenticationViewController,
49+
context: UIViewControllerRepresentableContext<GKAuthenticationView>) {
4750
}
4851
}
4952

@@ -60,28 +63,28 @@ public class GKAuthenticationViewController: UIViewController {
6063
self.failed = failed
6164
self.authenticated = authenticated
6265
super.init(nibName: nil, bundle: nil)
63-
}
64-
65-
required init?(coder: NSCoder) {
66-
fatalError("init(coder:) has not been implemented")
67-
}
68-
69-
public override func viewWillAppear(_ animated: Bool) {
70-
super.viewWillAppear(animated)
66+
// Setup internal observer for GameKit authentication changes
7167
NotificationCenter.default.addObserver(
7268
self,
7369
selector: #selector(GKAuthenticationViewController.authenticationChanged),
7470
name: Notification.Name.GKPlayerAuthenticationDidChangeNotificationName,
7571
object: nil
7672
)
77-
self.authenticate()
7873
}
7974

80-
public override func viewWillDisappear(_ animated: Bool) {
81-
super.viewWillDisappear(animated)
75+
required init?(coder: NSCoder) {
76+
fatalError("init(coder:) has not been implemented")
77+
}
78+
79+
deinit {
8280
NotificationCenter.default.removeObserver(self)
8381
}
8482

83+
public override func viewWillAppear(_ animated: Bool) {
84+
super.viewWillAppear(animated)
85+
self.authenticate()
86+
}
87+
8588
@objc fileprivate func authenticationChanged() {
8689
if GKLocalPlayer.local.isAuthenticated {
8790
self.stateChanged(.succeeded)

Tests/GameKitUITests/GameKitUITests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ final class GameKitUITests: XCTestCase {
1010
}
1111

1212
static var allTests = [
13-
("testExample", testExample),
13+
("testExample", testExample)
1414
]
1515
}

Tests/GameKitUITests/XCTestManifests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import XCTest
33
#if !canImport(ObjectiveC)
44
public func allTests() -> [XCTestCaseEntry] {
55
return [
6-
testCase(GameKitUITests.allTests),
6+
testCase(GameKitUITests.allTests)
77
]
88
}
99
#endif

0 commit comments

Comments
 (0)