From 7be4b1d66521c23cf59f96421dd94a629659d759 Mon Sep 17 00:00:00 2001 From: Eric Shepherd Date: Wed, 25 Sep 2024 15:02:04 -0400 Subject: [PATCH] Clean up before posting Did a few cleanup tasks to prepare for posting: * Added missing copyright headers and removed crufty default ones. * Removed the extension on `Task` that's no longer being used. * Added a frame constraint to the `SignInWithAppleButton` to stop getting runtime warnings logged by UIKit on newer iOS versions. --- .../Buckets/Buckets.xcodeproj/project.pbxproj | 4 --- .../apple/Buckets/Buckets/BucketsApp.swift | 9 +++---- .../apple/Buckets/Buckets/ContentView.swift | 2 +- .../Buckets/Support/LocalizedAlertError.swift | 8 ++---- .../Buckets/Support/Task-extension.swift | 27 ------------------- .../Buckets/Support/View-extension.swift | 8 ++---- 6 files changed, 8 insertions(+), 50 deletions(-) delete mode 100644 swift/example_code/apple/Buckets/Buckets/Support/Task-extension.swift diff --git a/swift/example_code/apple/Buckets/Buckets.xcodeproj/project.pbxproj b/swift/example_code/apple/Buckets/Buckets.xcodeproj/project.pbxproj index c6bb9292120..f7f7c617a2e 100644 --- a/swift/example_code/apple/Buckets/Buckets.xcodeproj/project.pbxproj +++ b/swift/example_code/apple/Buckets/Buckets.xcodeproj/project.pbxproj @@ -17,7 +17,6 @@ 283FA3A92C5D3697003CF6D9 /* IDString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 283FA3A82C5D3697003CF6D9 /* IDString.swift */; }; 283FA3AB2C5D36BC003CF6D9 /* BucketsAppError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 283FA3AA2C5D36BC003CF6D9 /* BucketsAppError.swift */; }; 286E157D2CA46392001D1009 /* SimpleKeychain in Frameworks */ = {isa = PBXBuildFile; productRef = 286E157C2CA46392001D1009 /* SimpleKeychain */; }; - 28FA46BE2C8A135700A2E959 /* Task-extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28FA46BD2C8A135700A2E959 /* Task-extension.swift */; }; 28FA46C02C8A139900A2E959 /* LocalizedAlertError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28FA46BF2C8A139900A2E959 /* LocalizedAlertError.swift */; }; 28FA46C22C8A145500A2E959 /* View-extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28FA46C12C8A145500A2E959 /* View-extension.swift */; }; /* End PBXBuildFile section */ @@ -32,7 +31,6 @@ 283FA3A12C5D3590003CF6D9 /* ContentView-ViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ContentView-ViewModel.swift"; sourceTree = ""; }; 283FA3A82C5D3697003CF6D9 /* IDString.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IDString.swift; sourceTree = ""; }; 283FA3AA2C5D36BC003CF6D9 /* BucketsAppError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BucketsAppError.swift; sourceTree = ""; }; - 28FA46BD2C8A135700A2E959 /* Task-extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Task-extension.swift"; sourceTree = ""; }; 28FA46BF2C8A139900A2E959 /* LocalizedAlertError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocalizedAlertError.swift; sourceTree = ""; }; 28FA46C12C8A145500A2E959 /* View-extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View-extension.swift"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -102,7 +100,6 @@ isa = PBXGroup; children = ( 283FA3A82C5D3697003CF6D9 /* IDString.swift */, - 28FA46BD2C8A135700A2E959 /* Task-extension.swift */, 28FA46C12C8A145500A2E959 /* View-extension.swift */, 28FA46BF2C8A139900A2E959 /* LocalizedAlertError.swift */, ); @@ -190,7 +187,6 @@ files = ( 283FA3AB2C5D36BC003CF6D9 /* BucketsAppError.swift in Sources */, 283FA3952C5D34FF003CF6D9 /* ContentView.swift in Sources */, - 28FA46BE2C8A135700A2E959 /* Task-extension.swift in Sources */, 283FA3A92C5D3697003CF6D9 /* IDString.swift in Sources */, 28FA46C22C8A145500A2E959 /* View-extension.swift in Sources */, 28FA46C02C8A139900A2E959 /* LocalizedAlertError.swift in Sources */, diff --git a/swift/example_code/apple/Buckets/Buckets/BucketsApp.swift b/swift/example_code/apple/Buckets/Buckets/BucketsApp.swift index 72fa5a5d28e..fe91779d17e 100644 --- a/swift/example_code/apple/Buckets/Buckets/BucketsApp.swift +++ b/swift/example_code/apple/Buckets/Buckets/BucketsApp.swift @@ -1,12 +1,9 @@ -// -// BucketsApp.swift -// Buckets -// -// Created by Shepherd, Eric on 8/2/24. -// +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 import SwiftUI +/// The main SwiftUI entry point. @main struct BucketsApp: App { var body: some Scene { diff --git a/swift/example_code/apple/Buckets/Buckets/ContentView.swift b/swift/example_code/apple/Buckets/Buckets/ContentView.swift index 5ced8806dfd..25fd009c903 100644 --- a/swift/example_code/apple/Buckets/Buckets/ContentView.swift +++ b/swift/example_code/apple/Buckets/Buckets/ContentView.swift @@ -60,7 +60,7 @@ struct ContentView: View { } } // snippet-end:[siwa-button.swift] - .frame(height: 60) + .frame(maxWidth: 340, maxHeight: 58) .keyboardShortcut(.defaultAction) } .padding() diff --git a/swift/example_code/apple/Buckets/Buckets/Support/LocalizedAlertError.swift b/swift/example_code/apple/Buckets/Buckets/Support/LocalizedAlertError.swift index 84cbe82b1d3..15829d86fa7 100644 --- a/swift/example_code/apple/Buckets/Buckets/Support/LocalizedAlertError.swift +++ b/swift/example_code/apple/Buckets/Buckets/Support/LocalizedAlertError.swift @@ -1,9 +1,5 @@ -// -// LocalizedAlertError.swift -// Buckets -// -// Created by Shepherd, Eric on 9/5/24. -// +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 import Foundation diff --git a/swift/example_code/apple/Buckets/Buckets/Support/Task-extension.swift b/swift/example_code/apple/Buckets/Buckets/Support/Task-extension.swift deleted file mode 100644 index 3581528dc43..00000000000 --- a/swift/example_code/apple/Buckets/Buckets/Support/Task-extension.swift +++ /dev/null @@ -1,27 +0,0 @@ -// -// Task-extension.swift -// Buckets -// -// Created by Shepherd, Eric on 9/5/24. -// - -import Foundation - -// Extend the `Task` class to add a `synchronous(priority:operation)` function -// by blocking until the task is complete. -extension Task where Failure == Error { - /// Performs an asynchronous task in a synchronous context. - /// - /// > Note: This function blocks the thread until the given operation is - /// finished. The caller is responsible for managing multithreading. - static func synchronous(priority: TaskPriority? = nil, operation: @escaping @Sendable () async throws -> Success) { - let semaphore = DispatchSemaphore(value: 0) - - Task(priority: priority) { - defer { semaphore.signal() } - return try await operation() - } - - semaphore.wait() - } -} diff --git a/swift/example_code/apple/Buckets/Buckets/Support/View-extension.swift b/swift/example_code/apple/Buckets/Buckets/Support/View-extension.swift index 64bbc17ca3c..e859e36d807 100644 --- a/swift/example_code/apple/Buckets/Buckets/Support/View-extension.swift +++ b/swift/example_code/apple/Buckets/Buckets/Support/View-extension.swift @@ -1,9 +1,5 @@ -// -// View-extension.swift -// Buckets -// -// Created by Shepherd, Eric on 9/5/24. -// +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 import Foundation import SwiftUI