From f3380847bb55fd1b916d73fff3e436905deb788b Mon Sep 17 00:00:00 2001 From: Mattia La Spina <119877139+mattials@users.noreply.github.com> Date: Mon, 8 Jan 2024 16:22:42 +0100 Subject: [PATCH] Fix BUG https://github.com/Azure/azure-sdk-for-ios/issues/1672 --- sdk/core/AzureCore/Source/Util/ApplicationUtil.swift | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/sdk/core/AzureCore/Source/Util/ApplicationUtil.swift b/sdk/core/AzureCore/Source/Util/ApplicationUtil.swift index 03ffd6939..ddc2f7979 100644 --- a/sdk/core/AzureCore/Source/Util/ApplicationUtil.swift +++ b/sdk/core/AzureCore/Source/Util/ApplicationUtil.swift @@ -25,9 +25,7 @@ // -------------------------------------------------------------------------- import Foundation -#if canImport(UIKit) - import UIKit -#endif +import UIKit public enum ApplicationUtil { // MARK: Static Methods @@ -41,9 +39,8 @@ public enum ApplicationUtil { return mainBundlePath.hasSuffix("appex") } - #if canImport(UIKit) - /// Simple access to the shared application when not executing within an app extension. + @available(iOSApplicationExtension, unavailable) public static var sharedApplication: UIApplication? { guard !isExecutingInAppExtension else { return nil } return UIApplication.shared @@ -52,6 +49,7 @@ public enum ApplicationUtil { /// Returns the current `UIViewController` for a parent controller. /// - Parameter parent: The parent `UIViewController`. If none provided, will attempt to discover the most /// relevant controller. + @available(iOSApplicationExtension, unavailable) public static func currentViewController(forParent parent: UIViewController? = nil) -> UIViewController? { // return the current view controller of the parent if let parent = parent { @@ -69,6 +67,7 @@ public enum ApplicationUtil { /// Attempt to find the top-most view controller for a given root view controller. /// - Parameter root: The root `UIViewController`. + @available(iOSApplicationExtension, unavailable) public static func currentViewController(withRootViewController root: UIViewController?) -> UIViewController? { if let tabBarController = root as? UITabBarController { return currentViewController(withRootViewController: tabBarController.selectedViewController) @@ -80,6 +79,4 @@ public enum ApplicationUtil { return root } } - - #endif }