Skip to content

Commit

Permalink
Linter cleanup
Browse files Browse the repository at this point in the history
 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)
  • Loading branch information
smuellner committed Nov 22, 2020
1 parent 18df7d6 commit 9b28750
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let package = Package(
products: [
.library(
name: "GameKitUI",
targets: ["GameKitUI"]),
targets: ["GameKitUI"])
],
dependencies: [
],
Expand All @@ -23,6 +23,6 @@ let package = Package(
dependencies: []),
.testTarget(
name: "GameKitUITests",
dependencies: ["GameKitUI"]),
dependencies: ["GameKitUI"])
]
)
29 changes: 16 additions & 13 deletions Sources/GameKitUI/GKAuthenticationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public struct GKAuthenticationView: UIViewControllerRepresentable {
public let failed: ((Error) -> Void)
public let authenticated: ((String) -> Void)

public func makeUIViewController(context: UIViewControllerRepresentableContext<GKAuthenticationView>) -> GKAuthenticationViewController {
public func makeUIViewController(
context: UIViewControllerRepresentableContext<GKAuthenticationView>) -> GKAuthenticationViewController {
let authenticationViewController = GKAuthenticationViewController { (state) in
self.state(state)
} failed: { (error) in
Expand All @@ -43,7 +44,9 @@ public struct GKAuthenticationView: UIViewControllerRepresentable {
return authenticationViewController
}

public func updateUIViewController(_ uiViewController: GKAuthenticationViewController, context: UIViewControllerRepresentableContext<GKAuthenticationView>) {
public func updateUIViewController(
_ uiViewController: GKAuthenticationViewController,
context: UIViewControllerRepresentableContext<GKAuthenticationView>) {
}
}

Expand All @@ -60,28 +63,28 @@ public class GKAuthenticationViewController: UIViewController {
self.failed = failed
self.authenticated = authenticated
super.init(nibName: nil, bundle: nil)
}

required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// Setup internal observer for GameKit authentication changes
NotificationCenter.default.addObserver(
self,
selector: #selector(GKAuthenticationViewController.authenticationChanged),
name: Notification.Name.GKPlayerAuthenticationDidChangeNotificationName,
object: nil
)
self.authenticate()
}

public override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}

deinit {
NotificationCenter.default.removeObserver(self)
}

public override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.authenticate()
}

@objc fileprivate func authenticationChanged() {
if GKLocalPlayer.local.isAuthenticated {
self.stateChanged(.succeeded)
Expand Down
2 changes: 1 addition & 1 deletion Tests/GameKitUITests/GameKitUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ final class GameKitUITests: XCTestCase {
}

static var allTests = [
("testExample", testExample),
("testExample", testExample)
]
}
2 changes: 1 addition & 1 deletion Tests/GameKitUITests/XCTestManifests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import XCTest
#if !canImport(ObjectiveC)
public func allTests() -> [XCTestCaseEntry] {
return [
testCase(GameKitUITests.allTests),
testCase(GameKitUITests.allTests)
]
}
#endif

0 comments on commit 9b28750

Please sign in to comment.