From de1a059fb654439481de435aaf02ace0cfd19d0d Mon Sep 17 00:00:00 2001 From: Khanh LeViet Date: Wed, 6 Sep 2023 20:47:08 -0700 Subject: [PATCH] Added missing SceneDelegate in ObjectDetector iOS sample --- .../ObjectDetector.xcodeproj/project.pbxproj | 4 ++ .../ios/ObjectDetector/SceneDelegate.swift | 59 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 examples/object_detection/ios/ObjectDetector/SceneDelegate.swift diff --git a/examples/object_detection/ios/ObjectDetector.xcodeproj/project.pbxproj b/examples/object_detection/ios/ObjectDetector.xcodeproj/project.pbxproj index 6fd9d646..1dd5d221 100644 --- a/examples/object_detection/ios/ObjectDetector.xcodeproj/project.pbxproj +++ b/examples/object_detection/ios/ObjectDetector.xcodeproj/project.pbxproj @@ -10,6 +10,7 @@ 39A04804C8101D2C0D58D927 /* libPods-ObjectDetectorTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = BF80BB442A677B6C005E93B1 /* libPods-ObjectDetectorTests.a */; }; 7F2ED5E52A97CEFD0044C53E /* coupleanddog.jpeg in Resources */ = {isa = PBXBuildFile; fileRef = BFCF18232A41476D00D64FA6 /* coupleanddog.jpeg */; }; 7F7641A62A74803D00DDCE4E /* download_models.sh in Resources */ = {isa = PBXBuildFile; fileRef = 7F7641A52A74803D00DDCE4E /* download_models.sh */; }; + 7FEC31BF2AA97EF20074D3D3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7FEC31BE2AA97EF20074D3D3 /* SceneDelegate.swift */; }; 9E41A7603AB8BE3B86C06DB9 /* Pods_ObjectDetector.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C3FBCABF9DABD56A270978F4 /* Pods_ObjectDetector.framework */; }; AAF981DB2A80D27500C7121A /* CameraViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAF981DA2A80D27500C7121A /* CameraViewController.swift */; }; AAF981DD2A80D28B00C7121A /* MediaLibraryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = AAF981DC2A80D28B00C7121A /* MediaLibraryViewController.swift */; }; @@ -44,6 +45,7 @@ 3867444B45D308637F45B36F /* Pods-ObjectDetectorTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ObjectDetectorTests.debug.xcconfig"; path = "Target Support Files/Pods-ObjectDetectorTests/Pods-ObjectDetectorTests.debug.xcconfig"; sourceTree = ""; }; 5C7001CA299F3F76944A9162 /* Pods-ObjectDetector.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-ObjectDetector.debug.xcconfig"; path = "Target Support Files/Pods-ObjectDetector/Pods-ObjectDetector.debug.xcconfig"; sourceTree = ""; }; 7F7641A52A74803D00DDCE4E /* download_models.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = download_models.sh; sourceTree = ""; }; + 7FEC31BE2AA97EF20074D3D3 /* SceneDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = ""; }; AAF981DA2A80D27500C7121A /* CameraViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CameraViewController.swift; sourceTree = ""; }; AAF981DC2A80D28B00C7121A /* MediaLibraryViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaLibraryViewController.swift; sourceTree = ""; }; AAF981DE2A81330700C7121A /* InferenceConfigManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InferenceConfigManager.swift; sourceTree = ""; }; @@ -179,6 +181,7 @@ BF2B2D672A3C0C3F00589A11 /* ViewControllers */, 7F7641A42A74803D00DDCE4E /* RunScripts */, BF2B2D2E2A3C09E200589A11 /* AppDelegate.swift */, + 7FEC31BE2AA97EF20074D3D3 /* SceneDelegate.swift */, BF2B2D342A3C09E200589A11 /* Main.storyboard */, BF2B2D372A3C09E300589A11 /* Assets.xcassets */, BF2B2D392A3C09E300589A11 /* LaunchScreen.storyboard */, @@ -399,6 +402,7 @@ AAF981DF2A81330700C7121A /* InferenceConfigManager.swift in Sources */, BF2B2D642A3C0C2900589A11 /* CameraFeedService.swift in Sources */, BF2B2D2F2A3C09E200589A11 /* AppDelegate.swift in Sources */, + 7FEC31BF2AA97EF20074D3D3 /* SceneDelegate.swift in Sources */, BF2B2D6D2A3C0EF900589A11 /* ObjectDetectorService.swift in Sources */, AAF981DD2A80D28B00C7121A /* MediaLibraryViewController.swift in Sources */, AAF981DB2A80D27500C7121A /* CameraViewController.swift in Sources */, diff --git a/examples/object_detection/ios/ObjectDetector/SceneDelegate.swift b/examples/object_detection/ios/ObjectDetector/SceneDelegate.swift new file mode 100644 index 00000000..d259406c --- /dev/null +++ b/examples/object_detection/ios/ObjectDetector/SceneDelegate.swift @@ -0,0 +1,59 @@ +// Copyright 2023 The MediaPipe Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +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). + guard let _ = (scene as? UIWindowScene) else { return } + } + + func sceneDidDisconnect(_ scene: 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 necessarily discarded (see `application:didDiscardSceneSessions` instead). + } + + func sceneDidBecomeActive(_ scene: 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(_ scene: 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(_ scene: 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(_ scene: 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. + } + + +} +