Skip to content

Commit 7406f61

Browse files
mdshakib007mdshakib007
andauthored
added fallback method for xcode detect & condition updated (#647)
Co-authored-by: mdshakib007 <shakib@mail.com>
1 parent b4ff069 commit 7406f61

3 files changed

Lines changed: 45 additions & 3 deletions

File tree

Framework/install_handler/ios/simulator.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,21 @@ async def _create_default_device() -> bool:
117117
await _send_status("error", f"Auto-creation of device failed: {e}")
118118
return False
119119

120+
121+
def fallback_is_xcode_installed() -> bool:
122+
try:
123+
result = subprocess.run(
124+
["xcode-select", "-p"],
125+
stdout=subprocess.PIPE,
126+
stderr=subprocess.PIPE,
127+
text=True,
128+
check=True
129+
)
130+
return bool(result.stdout.strip())
131+
except (subprocess.CalledProcessError, FileNotFoundError):
132+
return False
133+
134+
120135
async def check_status() -> bool:
121136
"""Check if iOS Simulator is installed and available."""
122137
print("[simulator] Checking status...")
@@ -125,7 +140,7 @@ async def check_status() -> bool:
125140
await _send_status("error", "Unsupported OS. iOS Simulator is only available on macOS.")
126141
return False
127142

128-
if not os.path.exists("/Applications/Xcode.app"):
143+
if not os.path.exists("/Applications/Xcode.app") and not fallback_is_xcode_installed():
129144
await _send_status("not installed", "Xcode must be installed before using iOS Simulator.")
130145
return False
131146

Framework/install_handler/ios/webdriver.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,21 @@ def _get_webdriver_path() -> Path:
2727
home = Path.home()
2828
return home / ".zeuz" / "WebDriverAgent"
2929

30+
def fallback_is_xcode_installed() -> bool:
31+
try:
32+
result = subprocess.run(
33+
["xcode-select", "-p"],
34+
stdout=subprocess.PIPE,
35+
stderr=subprocess.PIPE,
36+
text=True,
37+
check=True
38+
)
39+
return bool(result.stdout.strip())
40+
except (subprocess.CalledProcessError, FileNotFoundError):
41+
return False
42+
3043
async def _check_xcode_installed() -> bool:
31-
if not os.path.exists("/Applications/Xcode.app"):
44+
if not os.path.exists("/Applications/Xcode.app") and not fallback_is_xcode_installed():
3245
return False
3346
return shutil.which("xcodebuild") is not None
3447

Framework/install_handler/macos/common.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ async def _send_status(category, status: str, comment: str):
2121
)
2222

2323

24+
def fallback_is_xcode_installed() -> bool:
25+
try:
26+
result = subprocess.run(
27+
["xcode-select", "-p"],
28+
stdout=subprocess.PIPE,
29+
stderr=subprocess.PIPE,
30+
text=True,
31+
check=True
32+
)
33+
return bool(result.stdout.strip())
34+
except (subprocess.CalledProcessError, FileNotFoundError):
35+
return False
36+
37+
2438
async def xcode_check_status(category) -> bool:
2539
"""Check if Xcode is installed and license is accepted."""
2640
print("[xcode] Checking status...")
@@ -32,7 +46,7 @@ async def xcode_check_status(category) -> bool:
3246
return False
3347

3448
xcodebuild_path = shutil.which("xcodebuild")
35-
if not xcodebuild_path or not os.path.exists("/Applications/Xcode.app"):
49+
if not xcodebuild_path and not os.path.exists("/Applications/Xcode.app") and not fallback_is_xcode_installed():
3650
await _send_status(category, "not installed", "Xcode is not installed.")
3751
return False
3852

0 commit comments

Comments
 (0)