From a612aff8c0650552d81c531f0cfdffb305bad5f3 Mon Sep 17 00:00:00 2001 From: mdshakib007 Date: Sat, 17 Jan 2026 19:23:52 +0600 Subject: [PATCH] added fallback method for xcode detect & condition updated --- Framework/install_handler/ios/simulator.py | 17 ++++++++++++++++- Framework/install_handler/ios/webdriver.py | 15 ++++++++++++++- Framework/install_handler/macos/common.py | 16 +++++++++++++++- 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/Framework/install_handler/ios/simulator.py b/Framework/install_handler/ios/simulator.py index f3b5164f..2120e1c6 100644 --- a/Framework/install_handler/ios/simulator.py +++ b/Framework/install_handler/ios/simulator.py @@ -117,6 +117,21 @@ async def _create_default_device() -> bool: await _send_status("error", f"Auto-creation of device failed: {e}") return False + +def fallback_is_xcode_installed() -> bool: + try: + result = subprocess.run( + ["xcode-select", "-p"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True, + check=True + ) + return bool(result.stdout.strip()) + except (subprocess.CalledProcessError, FileNotFoundError): + return False + + async def check_status() -> bool: """Check if iOS Simulator is installed and available.""" print("[simulator] Checking status...") @@ -125,7 +140,7 @@ async def check_status() -> bool: await _send_status("error", "Unsupported OS. iOS Simulator is only available on macOS.") return False - if not os.path.exists("/Applications/Xcode.app"): + if not os.path.exists("/Applications/Xcode.app") and not fallback_is_xcode_installed(): await _send_status("not installed", "Xcode must be installed before using iOS Simulator.") return False diff --git a/Framework/install_handler/ios/webdriver.py b/Framework/install_handler/ios/webdriver.py index 6e5d0801..d66d88bb 100644 --- a/Framework/install_handler/ios/webdriver.py +++ b/Framework/install_handler/ios/webdriver.py @@ -27,8 +27,21 @@ def _get_webdriver_path() -> Path: home = Path.home() return home / ".zeuz" / "WebDriverAgent" +def fallback_is_xcode_installed() -> bool: + try: + result = subprocess.run( + ["xcode-select", "-p"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True, + check=True + ) + return bool(result.stdout.strip()) + except (subprocess.CalledProcessError, FileNotFoundError): + return False + async def _check_xcode_installed() -> bool: - if not os.path.exists("/Applications/Xcode.app"): + if not os.path.exists("/Applications/Xcode.app") and not fallback_is_xcode_installed(): return False return shutil.which("xcodebuild") is not None diff --git a/Framework/install_handler/macos/common.py b/Framework/install_handler/macos/common.py index 29e593d2..771b9a84 100644 --- a/Framework/install_handler/macos/common.py +++ b/Framework/install_handler/macos/common.py @@ -21,6 +21,20 @@ async def _send_status(category, status: str, comment: str): ) +def fallback_is_xcode_installed() -> bool: + try: + result = subprocess.run( + ["xcode-select", "-p"], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + text=True, + check=True + ) + return bool(result.stdout.strip()) + except (subprocess.CalledProcessError, FileNotFoundError): + return False + + async def xcode_check_status(category) -> bool: """Check if Xcode is installed and license is accepted.""" print("[xcode] Checking status...") @@ -32,7 +46,7 @@ async def xcode_check_status(category) -> bool: return False xcodebuild_path = shutil.which("xcodebuild") - if not xcodebuild_path or not os.path.exists("/Applications/Xcode.app"): + if not xcodebuild_path and not os.path.exists("/Applications/Xcode.app") and not fallback_is_xcode_installed(): await _send_status(category, "not installed", "Xcode is not installed.") return False