Skip to content

Commit

Permalink
Fix BUG Azure#1672
Browse files Browse the repository at this point in the history
  • Loading branch information
mattials authored Jan 8, 2024
1 parent 7b600ac commit f338084
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions sdk/core/AzureCore/Source/Util/ApplicationUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
// --------------------------------------------------------------------------

import Foundation
#if canImport(UIKit)
import UIKit
#endif
import UIKit

public enum ApplicationUtil {
// MARK: Static Methods
Expand All @@ -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
Expand All @@ -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 {
Expand All @@ -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)
Expand All @@ -80,6 +79,4 @@ public enum ApplicationUtil {
return root
}
}

#endif
}

0 comments on commit f338084

Please sign in to comment.