From 3acbe94b63236e6a7b854dd92eb469d14dfda671 Mon Sep 17 00:00:00 2001 From: Zhihui Xia Date: Mon, 15 Jul 2024 09:28:32 -0700 Subject: [PATCH] ios13 quick test --- .github/workflows/ci.yml | 2 +- .../MqttClient/MqttClient/ContentView.swift | 3 +- .../MqttClient/MqttClient/MqttClientApp.swift | 34 ++++++++++++++++++- 3 files changed, 35 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a105ee71..8cfb5de9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -164,7 +164,7 @@ jobs: --run_id ${{ github.run_id }} \ --run_attempt ${{ github.run_attempt }} \ --project_arn $(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/DeviceFarm/ProjectArn" --query "SecretString" | cut -f2 -d\") \ - --device_pool_arn $(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/DeviceFarm/iOSPoolArn" --query "SecretString" | cut -f2 -d\") \ + --device_pool_arn $(aws secretsmanager get-secret-value --region us-east-1 --secret-id "ci/DeviceFarm/iOS13PoolArn" --query "SecretString" | cut -f2 -d\") \ --app_file_path ./output/MqttClient.ipa \ --test_file_path ./workspace/test_bundle.zip \ --test_spec_file_path ./DeviceFarmScript/test_spec.yml diff --git a/Test/IntegrationTests/MqttClient/MqttClient/ContentView.swift b/Test/IntegrationTests/MqttClient/MqttClient/ContentView.swift index 9cd65ba0..ef81a3eb 100644 --- a/Test/IntegrationTests/MqttClient/MqttClient/ContentView.swift +++ b/Test/IntegrationTests/MqttClient/MqttClient/ContentView.swift @@ -11,9 +11,8 @@ let TEST_PORT: UInt32 = 1883 var mqttTestContext = MqttTestContext() var client: Mqtt5Client? -@available(iOS 14.0, *) struct ContentView: View { - @StateObject var testContext = mqttTestContext + @ObservedObject var testContext = mqttTestContext var body: some View { VStack { Button("Setup Client and Start") { diff --git a/Test/IntegrationTests/MqttClient/MqttClient/MqttClientApp.swift b/Test/IntegrationTests/MqttClient/MqttClient/MqttClientApp.swift index bf1d2b90..0855dfb6 100644 --- a/Test/IntegrationTests/MqttClient/MqttClient/MqttClientApp.swift +++ b/Test/IntegrationTests/MqttClient/MqttClient/MqttClientApp.swift @@ -3,8 +3,22 @@ import SwiftUI -@available(iOS 14.0, *) + @main +struct MqttClientAppWrapper { + static func main() { + if #available(iOS 14.0, *) { + MqttClientApp.main() + } + else { + // The main actor only exists for 14.0 and above. + UIApplicationMain(CommandLine.argc, CommandLine.unsafeArgv, nil, NSStringFromClass(SceneDelegate.self)) + } + } +} + + +@available(iOS 14.0, *) struct MqttClientApp: App { var body: some Scene { WindowGroup { @@ -12,3 +26,21 @@ struct MqttClientApp: App { } } } + + +class SceneDelegate: UIResponder, UIWindowSceneDelegate { + + var window: UIWindow? + + func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { + 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() + } + } +}