From b96b66b3e267f521e1f56182796624971f3a139e Mon Sep 17 00:00:00 2001 From: stevapple Date: Sat, 25 Sep 2021 10:34:36 +0800 Subject: [PATCH 1/4] Use a more modern app example --- .../MyApp/MyApp.xcodeproj/project.pbxproj | 173 +++++++++--------- .../contents.xcworkspacedata | 7 + .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../xcshareddata/xcschemes/MyApp.xcscheme | 78 -------- .../MyApp/MyApp/AppDelegate.swift | 37 ---- .../MyApp/Base.lproj/LaunchScreen.storyboard | 25 --- .../MyApp/MyApp/ContentView.swift | 65 ++++--- .../LocalDebugging/MyApp/MyApp/Info.plist | 60 ------ .../LocalDebugging/MyApp/MyApp/MyApp.swift | 24 +++ .../MyApp/MyApp/SceneDelegate.swift | 65 ------- 10 files changed, 157 insertions(+), 385 deletions(-) create mode 100644 Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata create mode 100644 Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist delete mode 100644 Examples/LocalDebugging/MyApp/MyApp.xcodeproj/xcshareddata/xcschemes/MyApp.xcscheme delete mode 100644 Examples/LocalDebugging/MyApp/MyApp/AppDelegate.swift delete mode 100644 Examples/LocalDebugging/MyApp/MyApp/Base.lproj/LaunchScreen.storyboard delete mode 100644 Examples/LocalDebugging/MyApp/MyApp/Info.plist create mode 100644 Examples/LocalDebugging/MyApp/MyApp/MyApp.swift delete mode 100644 Examples/LocalDebugging/MyApp/MyApp/SceneDelegate.swift diff --git a/Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.pbxproj b/Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.pbxproj index 9910fb6e..0ac2539a 100644 --- a/Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.pbxproj +++ b/Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.pbxproj @@ -3,82 +3,74 @@ archiveVersion = 1; classes = { }; - objectVersion = 52; + objectVersion = 55; objects = { /* Begin PBXBuildFile section */ - F7B6C1FE246121E800607A89 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7B6C1FD246121E800607A89 /* AppDelegate.swift */; }; - F7B6C200246121E800607A89 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7B6C1FF246121E800607A89 /* SceneDelegate.swift */; }; - F7B6C202246121E800607A89 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7B6C201246121E800607A89 /* ContentView.swift */; }; - F7B6C204246121E900607A89 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F7B6C203246121E900607A89 /* Assets.xcassets */; }; - F7B6C207246121E900607A89 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F7B6C206246121E900607A89 /* Preview Assets.xcassets */; }; - F7B6C20A246121E900607A89 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7B6C208246121E900607A89 /* LaunchScreen.storyboard */; }; - F7EA8D6024762E4000B0D09E /* Shared in Frameworks */ = {isa = PBXBuildFile; productRef = F7EA8D5F24762E4000B0D09E /* Shared */; }; + 7CD1174B26FE468F007DD17A /* MyApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CD1174A26FE468F007DD17A /* MyApp.swift */; }; + 7CD1174D26FE468F007DD17A /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CD1174C26FE468F007DD17A /* ContentView.swift */; }; + 7CD1174F26FE4692007DD17A /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7CD1174E26FE4692007DD17A /* Assets.xcassets */; }; + 7CD1175226FE4692007DD17A /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7CD1175126FE4692007DD17A /* Preview Assets.xcassets */; }; + 7CD1175A26FE4F44007DD17A /* Shared in Frameworks */ = {isa = PBXBuildFile; productRef = 7CD1175926FE4F44007DD17A /* Shared */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - F7B6C1FA246121E800607A89 /* MyApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MyApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; - F7B6C1FD246121E800607A89 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - F7B6C1FF246121E800607A89 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; - F7B6C201246121E800607A89 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; - F7B6C203246121E900607A89 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - F7B6C206246121E900607A89 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; - F7B6C209246121E900607A89 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; - F7B6C20B246121E900607A89 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 7CD1174726FE468F007DD17A /* MyApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MyApp.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 7CD1174A26FE468F007DD17A /* MyApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyApp.swift; sourceTree = ""; }; + 7CD1174C26FE468F007DD17A /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + 7CD1174E26FE4692007DD17A /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 7CD1175126FE4692007DD17A /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ - F7B6C1F7246121E800607A89 /* Frameworks */ = { + 7CD1174426FE468F007DD17A /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - F7EA8D6024762E4000B0D09E /* Shared in Frameworks */, + 7CD1175A26FE4F44007DD17A /* Shared in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - F7B6C1F1246121E800607A89 = { + 7CD1173E26FE468F007DD17A = { isa = PBXGroup; children = ( - F7B6C1FC246121E800607A89 /* MyApp */, - F7B6C1FB246121E800607A89 /* Products */, - F7EA8D5E24762E4000B0D09E /* Frameworks */, + 7CD1174926FE468F007DD17A /* MyApp */, + 7CD1174826FE468F007DD17A /* Products */, + 7CD1175826FE4F44007DD17A /* Frameworks */, ); sourceTree = ""; }; - F7B6C1FB246121E800607A89 /* Products */ = { + 7CD1174826FE468F007DD17A /* Products */ = { isa = PBXGroup; children = ( - F7B6C1FA246121E800607A89 /* MyApp.app */, + 7CD1174726FE468F007DD17A /* MyApp.app */, ); name = Products; sourceTree = ""; }; - F7B6C1FC246121E800607A89 /* MyApp */ = { + 7CD1174926FE468F007DD17A /* MyApp */ = { isa = PBXGroup; children = ( - F7B6C1FD246121E800607A89 /* AppDelegate.swift */, - F7B6C1FF246121E800607A89 /* SceneDelegate.swift */, - F7B6C201246121E800607A89 /* ContentView.swift */, - F7B6C203246121E900607A89 /* Assets.xcassets */, - F7B6C208246121E900607A89 /* LaunchScreen.storyboard */, - F7B6C20B246121E900607A89 /* Info.plist */, - F7B6C205246121E900607A89 /* Preview Content */, + 7CD1174A26FE468F007DD17A /* MyApp.swift */, + 7CD1174C26FE468F007DD17A /* ContentView.swift */, + 7CD1174E26FE4692007DD17A /* Assets.xcassets */, + 7CD1175026FE4692007DD17A /* Preview Content */, ); path = MyApp; sourceTree = ""; }; - F7B6C205246121E900607A89 /* Preview Content */ = { + 7CD1175026FE4692007DD17A /* Preview Content */ = { isa = PBXGroup; children = ( - F7B6C206246121E900607A89 /* Preview Assets.xcassets */, + 7CD1175126FE4692007DD17A /* Preview Assets.xcassets */, ); path = "Preview Content"; sourceTree = ""; }; - F7EA8D5E24762E4000B0D09E /* Frameworks */ = { + 7CD1175826FE4F44007DD17A /* Frameworks */ = { isa = PBXGroup; children = ( ); @@ -88,13 +80,13 @@ /* End PBXGroup section */ /* Begin PBXNativeTarget section */ - F7B6C1F9246121E800607A89 /* MyApp */ = { + 7CD1174626FE468F007DD17A /* MyApp */ = { isa = PBXNativeTarget; - buildConfigurationList = F7B6C20E246121E900607A89 /* Build configuration list for PBXNativeTarget "MyApp" */; + buildConfigurationList = 7CD1175526FE4692007DD17A /* Build configuration list for PBXNativeTarget "MyApp" */; buildPhases = ( - F7B6C1F6246121E800607A89 /* Sources */, - F7B6C1F7246121E800607A89 /* Frameworks */, - F7B6C1F8246121E800607A89 /* Resources */, + 7CD1174326FE468F007DD17A /* Sources */, + 7CD1174426FE468F007DD17A /* Frameworks */, + 7CD1174526FE468F007DD17A /* Resources */, ); buildRules = ( ); @@ -102,90 +94,77 @@ ); name = MyApp; packageProductDependencies = ( - F7EA8D5F24762E4000B0D09E /* Shared */, + 7CD1175926FE4F44007DD17A /* Shared */, ); productName = MyApp; - productReference = F7B6C1FA246121E800607A89 /* MyApp.app */; + productReference = 7CD1174726FE468F007DD17A /* MyApp.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ - F7B6C1F2246121E800607A89 /* Project object */ = { + 7CD1173F26FE468F007DD17A /* Project object */ = { isa = PBXProject; attributes = { - LastSwiftUpdateCheck = 1140; + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1300; LastUpgradeCheck = 1300; - ORGANIZATIONNAME = "Tom Doron"; TargetAttributes = { - F7B6C1F9246121E800607A89 = { - CreatedOnToolsVersion = 11.4.1; + 7CD1174626FE468F007DD17A = { + CreatedOnToolsVersion = 13.0; }; }; }; - buildConfigurationList = F7B6C1F5246121E800607A89 /* Build configuration list for PBXProject "MyApp" */; - compatibilityVersion = "Xcode 9.3"; + buildConfigurationList = 7CD1174226FE468F007DD17A /* Build configuration list for PBXProject "MyApp" */; + compatibilityVersion = "Xcode 13.0"; developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, Base, ); - mainGroup = F7B6C1F1246121E800607A89; - productRefGroup = F7B6C1FB246121E800607A89 /* Products */; + mainGroup = 7CD1173E26FE468F007DD17A; + productRefGroup = 7CD1174826FE468F007DD17A /* Products */; projectDirPath = ""; projectRoot = ""; targets = ( - F7B6C1F9246121E800607A89 /* MyApp */, + 7CD1174626FE468F007DD17A /* MyApp */, ); }; /* End PBXProject section */ /* Begin PBXResourcesBuildPhase section */ - F7B6C1F8246121E800607A89 /* Resources */ = { + 7CD1174526FE468F007DD17A /* Resources */ = { isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( - F7B6C20A246121E900607A89 /* LaunchScreen.storyboard in Resources */, - F7B6C207246121E900607A89 /* Preview Assets.xcassets in Resources */, - F7B6C204246121E900607A89 /* Assets.xcassets in Resources */, + 7CD1175226FE4692007DD17A /* Preview Assets.xcassets in Resources */, + 7CD1174F26FE4692007DD17A /* Assets.xcassets in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXResourcesBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ - F7B6C1F6246121E800607A89 /* Sources */ = { + 7CD1174326FE468F007DD17A /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - F7B6C1FE246121E800607A89 /* AppDelegate.swift in Sources */, - F7B6C200246121E800607A89 /* SceneDelegate.swift in Sources */, - F7B6C202246121E800607A89 /* ContentView.swift in Sources */, + 7CD1174D26FE468F007DD17A /* ContentView.swift in Sources */, + 7CD1174B26FE468F007DD17A /* MyApp.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXSourcesBuildPhase section */ -/* Begin PBXVariantGroup section */ - F7B6C208246121E900607A89 /* LaunchScreen.storyboard */ = { - isa = PBXVariantGroup; - children = ( - F7B6C209246121E900607A89 /* Base */, - ); - name = LaunchScreen.storyboard; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - /* Begin XCBuildConfiguration section */ - F7B6C20C246121E900607A89 /* Debug */ = { + 7CD1175326FE4692007DD17A /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; @@ -240,13 +219,13 @@ }; name = Debug; }; - F7B6C20D246121E900607A89 /* Release */ = { + 7CD1175426FE4692007DD17A /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; @@ -295,39 +274,59 @@ }; name = Release; }; - F7B6C20F246121E900607A89 /* Debug */ = { + 7CD1175626FE4692007DD17A /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"MyApp/Preview Content\""; ENABLE_PREVIEWS = YES; - INFOPLIST_FILE = MyApp/Info.plist; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); + MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.apple.swift.MyApp; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; }; - F7B6C210246121E900607A89 /* Release */ = { + 7CD1175726FE4692007DD17A /* Release */ = { isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; DEVELOPMENT_ASSET_PATHS = "\"MyApp/Preview Content\""; ENABLE_PREVIEWS = YES; - INFOPLIST_FILE = MyApp/Info.plist; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; LD_RUNPATH_SEARCH_PATHS = ( "$(inherited)", "@executable_path/Frameworks", ); + MARKETING_VERSION = 1.0; PRODUCT_BUNDLE_IDENTIFIER = com.apple.swift.MyApp; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; @@ -336,20 +335,20 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - F7B6C1F5246121E800607A89 /* Build configuration list for PBXProject "MyApp" */ = { + 7CD1174226FE468F007DD17A /* Build configuration list for PBXProject "MyApp" */ = { isa = XCConfigurationList; buildConfigurations = ( - F7B6C20C246121E900607A89 /* Debug */, - F7B6C20D246121E900607A89 /* Release */, + 7CD1175326FE4692007DD17A /* Debug */, + 7CD1175426FE4692007DD17A /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - F7B6C20E246121E900607A89 /* Build configuration list for PBXNativeTarget "MyApp" */ = { + 7CD1175526FE4692007DD17A /* Build configuration list for PBXNativeTarget "MyApp" */ = { isa = XCConfigurationList; buildConfigurations = ( - F7B6C20F246121E900607A89 /* Debug */, - F7B6C210246121E900607A89 /* Release */, + 7CD1175626FE4692007DD17A /* Debug */, + 7CD1175726FE4692007DD17A /* Release */, ); defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; @@ -357,11 +356,11 @@ /* End XCConfigurationList section */ /* Begin XCSwiftPackageProductDependency section */ - F7EA8D5F24762E4000B0D09E /* Shared */ = { + 7CD1175926FE4F44007DD17A /* Shared */ = { isa = XCSwiftPackageProductDependency; productName = Shared; }; /* End XCSwiftPackageProductDependency section */ }; - rootObject = F7B6C1F2246121E800607A89 /* Project object */; + rootObject = 7CD1173F26FE468F007DD17A /* Project object */; } diff --git a/Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 00000000..919434a6 --- /dev/null +++ b/Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 00000000..18d98100 --- /dev/null +++ b/Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Examples/LocalDebugging/MyApp/MyApp.xcodeproj/xcshareddata/xcschemes/MyApp.xcscheme b/Examples/LocalDebugging/MyApp/MyApp.xcodeproj/xcshareddata/xcschemes/MyApp.xcscheme deleted file mode 100644 index eb84eb92..00000000 --- a/Examples/LocalDebugging/MyApp/MyApp.xcodeproj/xcshareddata/xcschemes/MyApp.xcscheme +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Examples/LocalDebugging/MyApp/MyApp/AppDelegate.swift b/Examples/LocalDebugging/MyApp/MyApp/AppDelegate.swift deleted file mode 100644 index 068d2b7a..00000000 --- a/Examples/LocalDebugging/MyApp/MyApp/AppDelegate.swift +++ /dev/null @@ -1,37 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the SwiftAWSLambdaRuntime open source project -// -// Copyright (c) 2020 Apple Inc. and the SwiftAWSLambdaRuntime project authors -// Licensed under Apache License v2.0 -// -// See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors -// -// SPDX-License-Identifier: Apache-2.0 -// -//===----------------------------------------------------------------------===// - -import UIKit - -@UIApplicationMain -class AppDelegate: UIResponder, UIApplicationDelegate { - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { - // Override point for customization after application launch. - true - } - - // MARK: UISceneSession Lifecycle - - func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration { - // Called when a new scene session is being created. - // Use this method to select a configuration to create the new scene with. - UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role) - } - - func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set) { - // Called when the user discards a scene session. - // If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions. - // Use this method to release any resources that were specific to the discarded scenes, as they will not return. - } -} diff --git a/Examples/LocalDebugging/MyApp/MyApp/Base.lproj/LaunchScreen.storyboard b/Examples/LocalDebugging/MyApp/MyApp/Base.lproj/LaunchScreen.storyboard deleted file mode 100644 index 865e9329..00000000 --- a/Examples/LocalDebugging/MyApp/MyApp/Base.lproj/LaunchScreen.storyboard +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Examples/LocalDebugging/MyApp/MyApp/ContentView.swift b/Examples/LocalDebugging/MyApp/MyApp/ContentView.swift index 459d4312..4f5f3696 100644 --- a/Examples/LocalDebugging/MyApp/MyApp/ContentView.swift +++ b/Examples/LocalDebugging/MyApp/MyApp/ContentView.swift @@ -2,7 +2,7 @@ // // This source file is part of the SwiftAWSLambdaRuntime open source project // -// Copyright (c) 2020 Apple Inc. and the SwiftAWSLambdaRuntime project authors +// Copyright (c) 2021 Apple Inc. and the SwiftAWSLambdaRuntime project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information @@ -19,31 +19,40 @@ struct ContentView: View { @State var name: String = "" @State var password: String = "" @State var response: String = "" + @State private var isLoading: Bool = false var body: some View { VStack(alignment: .leading, spacing: 20) { TextField("Username", text: $name) SecureField("Password", text: $password) - Button( - action: { - Task { - await self.register() - } - }, - label: { - Text("Register") - .padding() - .foregroundColor(.white) - .background(Color.black) - .border(Color.black, width: 2) + let buttonDisabled = name.isEmpty || password.isEmpty + Button { + Task { + isLoading = true + response = await register() + isLoading = false } - ) + } label: { + Text("Register") + .padding() + .foregroundColor(.white) + .background(.black) + .border(.black, width: 2) + .opacity(isLoading ? 0 : 1) + .overlay { + if isLoading { + ProgressView() + } + } + } + .disabled(buttonDisabled) + .opacity(buttonDisabled ? 0.5 : 1) Text(response) }.padding(100) } - func register() async { - guard let url = URL(string: "http://127.0.0.1:7000/invoke") else { + func register() async -> String { + guard let url = URL(string: "http://localhost:9001/invoke") else { fatalError("invalid url") } var request = URLRequest(url: url) @@ -55,25 +64,19 @@ struct ContentView: View { request.httpBody = jsonRequest do { - let (data, response) = try await URLSession.shared.data(for: request) + let (data, urlResponse) = try await URLSession.shared.data(for: request) - guard let httpResponse = response as? HTTPURLResponse else { - throw CommunicationError(reason: "invalid response, expected HTTPURLResponse") + guard let httpResponse = urlResponse as? HTTPURLResponse else { + return "invalid response, expected HTTPURLResponse" } guard httpResponse.statusCode == 200 else { - throw CommunicationError(reason: "invalid response code: \(httpResponse.statusCode)") + return "invalid response code: \(httpResponse.statusCode)" } - let jsonResponse = try JSONDecoder().decode(Response.self, from: data) - self.response = jsonResponse.message + let response = try JSONDecoder().decode(Response.self, from: data) + return response.message } catch { - self.response = error.localizedDescription - } - } - - func setResponse(_ text: String) { - DispatchQueue.main.async { - self.response = text + return error.localizedDescription } } } @@ -83,7 +86,3 @@ struct ContentView_Previews: PreviewProvider { ContentView() } } - -struct CommunicationError: Error { - let reason: String -} diff --git a/Examples/LocalDebugging/MyApp/MyApp/Info.plist b/Examples/LocalDebugging/MyApp/MyApp/Info.plist deleted file mode 100644 index 9742bf0f..00000000 --- a/Examples/LocalDebugging/MyApp/MyApp/Info.plist +++ /dev/null @@ -1,60 +0,0 @@ - - - - - CFBundleDevelopmentRegion - $(DEVELOPMENT_LANGUAGE) - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - $(PRODUCT_BUNDLE_PACKAGE_TYPE) - CFBundleShortVersionString - 1.0 - CFBundleVersion - 1 - LSRequiresIPhoneOS - - UIApplicationSceneManifest - - UIApplicationSupportsMultipleScenes - - UISceneConfigurations - - UIWindowSceneSessionRoleApplication - - - UISceneConfigurationName - Default Configuration - UISceneDelegateClassName - $(PRODUCT_MODULE_NAME).SceneDelegate - - - - - UILaunchStoryboardName - LaunchScreen - UIRequiredDeviceCapabilities - - armv7 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - - diff --git a/Examples/LocalDebugging/MyApp/MyApp/MyApp.swift b/Examples/LocalDebugging/MyApp/MyApp/MyApp.swift new file mode 100644 index 00000000..8b4ae638 --- /dev/null +++ b/Examples/LocalDebugging/MyApp/MyApp/MyApp.swift @@ -0,0 +1,24 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the SwiftAWSLambdaRuntime open source project +// +// Copyright (c) 2021 Apple Inc. and the SwiftAWSLambdaRuntime project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + +import SwiftUI + +@main +struct MyApp: App { + var body: some Scene { + WindowGroup { + ContentView() + } + } +} diff --git a/Examples/LocalDebugging/MyApp/MyApp/SceneDelegate.swift b/Examples/LocalDebugging/MyApp/MyApp/SceneDelegate.swift deleted file mode 100644 index 71e700d4..00000000 --- a/Examples/LocalDebugging/MyApp/MyApp/SceneDelegate.swift +++ /dev/null @@ -1,65 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the SwiftAWSLambdaRuntime open source project -// -// Copyright (c) 2020 Apple Inc. and the SwiftAWSLambdaRuntime project authors -// Licensed under Apache License v2.0 -// -// See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors -// -// SPDX-License-Identifier: Apache-2.0 -// -//===----------------------------------------------------------------------===// - -import SwiftUI -import UIKit - -class SceneDelegate: UIResponder, UIWindowSceneDelegate { - var window: UIWindow? - - func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { - // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`. - // If using a storyboard, the `window` property will automatically be initialized and attached to the scene. - // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead). - - // Create the SwiftUI view that provides the window contents. - let contentView = ContentView() - - // Use a UIHostingController as window root view controller. - if let windowScene = scene as? UIWindowScene { - let window = UIWindow(windowScene: windowScene) - window.rootViewController = UIHostingController(rootView: contentView) - self.window = window - window.makeKeyAndVisible() - } - } - - func sceneDidDisconnect(_: UIScene) { - // Called as the scene is being released by the system. - // This occurs shortly after the scene enters the background, or when its session is discarded. - // Release any resources associated with this scene that can be re-created the next time the scene connects. - // The scene may re-connect later, as its session was not neccessarily discarded (see `application:didDiscardSceneSessions` instead). - } - - func sceneDidBecomeActive(_: UIScene) { - // Called when the scene has moved from an inactive state to an active state. - // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive. - } - - func sceneWillResignActive(_: UIScene) { - // Called when the scene will move from an active state to an inactive state. - // This may occur due to temporary interruptions (ex. an incoming phone call). - } - - func sceneWillEnterForeground(_: UIScene) { - // Called as the scene transitions from the background to the foreground. - // Use this method to undo the changes made on entering the background. - } - - func sceneDidEnterBackground(_: UIScene) { - // Called as the scene transitions from the foreground to the background. - // Use this method to save data, release shared resources, and store enough scene-specific state information - // to restore the scene back to its current state. - } -} From b16d0c80e694e32519668773afa2ab90200d969d Mon Sep 17 00:00:00 2001 From: stevapple Date: Sat, 25 Sep 2021 10:35:05 +0800 Subject: [PATCH 2/4] Update Swift version --- Examples/LocalDebugging/MyLambda/Dockerfile | 2 +- Examples/LocalDebugging/MyLambda/Lambda.swift | 2 +- Examples/LocalDebugging/Shared/Package.swift | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Examples/LocalDebugging/MyLambda/Dockerfile b/Examples/LocalDebugging/MyLambda/Dockerfile index d5315703..32962859 100644 --- a/Examples/LocalDebugging/MyLambda/Dockerfile +++ b/Examples/LocalDebugging/MyLambda/Dockerfile @@ -1,3 +1,3 @@ -FROM swift:5.2-amazonlinux2 +FROM swift:5.5-amazonlinux2 RUN yum -y install zip diff --git a/Examples/LocalDebugging/MyLambda/Lambda.swift b/Examples/LocalDebugging/MyLambda/Lambda.swift index b6a5d865..c31505fb 100644 --- a/Examples/LocalDebugging/MyLambda/Lambda.swift +++ b/Examples/LocalDebugging/MyLambda/Lambda.swift @@ -2,7 +2,7 @@ // // This source file is part of the SwiftAWSLambdaRuntime open source project // -// Copyright (c) 2020 Apple Inc. and the SwiftAWSLambdaRuntime project authors +// Copyright (c) 2020-2021 Apple Inc. and the SwiftAWSLambdaRuntime project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information diff --git a/Examples/LocalDebugging/Shared/Package.swift b/Examples/LocalDebugging/Shared/Package.swift index 3ab44d3f..96eb2003 100644 --- a/Examples/LocalDebugging/Shared/Package.swift +++ b/Examples/LocalDebugging/Shared/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.2 +// swift-tools-version:5.5 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription From 2b48c135a3f5d0ee511b49b0d98866937016e943 Mon Sep 17 00:00:00 2001 From: YR Chen Date: Mon, 27 Sep 2021 07:57:12 +0800 Subject: [PATCH 3/4] Minor Fixes --- .../project.xcworkspace/contents.xcworkspacedata | 7 ------- .../xcshareddata/IDEWorkspaceChecks.plist | 8 -------- .../LocalDebugging/MyApp/MyApp/ContentView.swift | 16 ++++++++-------- scripts/soundness.sh | 2 +- 4 files changed, 9 insertions(+), 24 deletions(-) delete mode 100644 Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata delete mode 100644 Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 919434a6..00000000 --- a/Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d98100..00000000 --- a/Examples/LocalDebugging/MyApp/MyApp.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/Examples/LocalDebugging/MyApp/MyApp/ContentView.swift b/Examples/LocalDebugging/MyApp/MyApp/ContentView.swift index 4f5f3696..e8cdec8f 100644 --- a/Examples/LocalDebugging/MyApp/MyApp/ContentView.swift +++ b/Examples/LocalDebugging/MyApp/MyApp/ContentView.swift @@ -2,7 +2,7 @@ // // This source file is part of the SwiftAWSLambdaRuntime open source project // -// Copyright (c) 2021 Apple Inc. and the SwiftAWSLambdaRuntime project authors +// Copyright (c) 2020-2021 Apple Inc. and the SwiftAWSLambdaRuntime project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information @@ -29,7 +29,7 @@ struct ContentView: View { Button { Task { isLoading = true - response = await register() + response = await self.register() isLoading = false } } label: { @@ -45,14 +45,14 @@ struct ContentView: View { } } } - .disabled(buttonDisabled) + .disabled(buttonDisabled || isLoading) .opacity(buttonDisabled ? 0.5 : 1) Text(response) }.padding(100) } func register() async -> String { - guard let url = URL(string: "http://localhost:9001/invoke") else { + guard let url = URL(string: "http://127.0.0.1:7000/invoke") else { fatalError("invalid url") } var request = URLRequest(url: url) @@ -64,17 +64,17 @@ struct ContentView: View { request.httpBody = jsonRequest do { - let (data, urlResponse) = try await URLSession.shared.data(for: request) + let (data, response) = try await URLSession.shared.data(for: request) - guard let httpResponse = urlResponse as? HTTPURLResponse else { + guard let httpResponse = response as? HTTPURLResponse else { return "invalid response, expected HTTPURLResponse" } guard httpResponse.statusCode == 200 else { return "invalid response code: \(httpResponse.statusCode)" } - let response = try JSONDecoder().decode(Response.self, from: data) - return response.message + let jsonResponse = try JSONDecoder().decode(Response.self, from: data) + return jsonResponse.message } catch { return error.localizedDescription } diff --git a/scripts/soundness.sh b/scripts/soundness.sh index 4fb39549..eb9e173b 100755 --- a/scripts/soundness.sh +++ b/scripts/soundness.sh @@ -19,7 +19,7 @@ here="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" function replace_acceptable_years() { # this needs to replace all acceptable forms with 'YEARS' - sed -e 's/2017-2018/YEARS/' -e 's/2017-2020/YEARS/' -e 's/2017-2021/YEARS/' -e 's/2019/YEARS/' -e 's/2020/YEARS/' -e 's/2021/YEARS/' + sed -e 's/2017-2018/YEARS/' -e 's/2017-2020/YEARS/' -e 's/2017-2021/YEARS/' -e 's/2020-2021/YEARS/' -e 's/2019/YEARS/' -e 's/2020/YEARS/' -e 's/2021/YEARS/' } printf "=> Checking for unacceptable language... " From 3c8345f9a998acc321f9e11fab8659127505163b Mon Sep 17 00:00:00 2001 From: stevapple Date: Tue, 28 Sep 2021 18:35:56 +0800 Subject: [PATCH 4/4] Update ContentView.swift --- .../MyApp/MyApp/ContentView.swift | 43 +++++++++++-------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/Examples/LocalDebugging/MyApp/MyApp/ContentView.swift b/Examples/LocalDebugging/MyApp/MyApp/ContentView.swift index e8cdec8f..4c7d3158 100644 --- a/Examples/LocalDebugging/MyApp/MyApp/ContentView.swift +++ b/Examples/LocalDebugging/MyApp/MyApp/ContentView.swift @@ -25,11 +25,15 @@ struct ContentView: View { VStack(alignment: .leading, spacing: 20) { TextField("Username", text: $name) SecureField("Password", text: $password) - let buttonDisabled = name.isEmpty || password.isEmpty + let inputIncomplete = name.isEmpty || password.isEmpty Button { Task { isLoading = true - response = await self.register() + do { + response = try await self.register() + } catch { + response = error.localizedDescription + } isLoading = false } } label: { @@ -45,13 +49,13 @@ struct ContentView: View { } } } - .disabled(buttonDisabled || isLoading) - .opacity(buttonDisabled ? 0.5 : 1) + .disabled(inputIncomplete || isLoading) + .opacity(inputIncomplete ? 0.5 : 1) Text(response) }.padding(100) } - func register() async -> String { + func register() async throws -> String { guard let url = URL(string: "http://127.0.0.1:7000/invoke") else { fatalError("invalid url") } @@ -63,21 +67,17 @@ struct ContentView: View { } request.httpBody = jsonRequest - do { - let (data, response) = try await URLSession.shared.data(for: request) + let (data, response) = try await URLSession.shared.data(for: request) - guard let httpResponse = response as? HTTPURLResponse else { - return "invalid response, expected HTTPURLResponse" - } - guard httpResponse.statusCode == 200 else { - return "invalid response code: \(httpResponse.statusCode)" - } - - let jsonResponse = try JSONDecoder().decode(Response.self, from: data) - return jsonResponse.message - } catch { - return error.localizedDescription + guard let httpResponse = response as? HTTPURLResponse else { + throw CommunicationError(reason: "Invalid response, expected HTTPURLResponse.") + } + guard httpResponse.statusCode == 200 else { + throw CommunicationError(reason: "Invalid response code: \(httpResponse.statusCode)") } + + let jsonResponse = try JSONDecoder().decode(Response.self, from: data) + return jsonResponse.message } } @@ -86,3 +86,10 @@ struct ContentView_Previews: PreviewProvider { ContentView() } } + +struct CommunicationError: LocalizedError { + let reason: String + var errorDescription: String? { + self.reason + } +}