Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion lib/clean/app_caches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,20 @@ clean_xcode_tools() {
# (can launch an invisible install dialog or wait on CoreSimulator XPC indefinitely).
if command -v xcrun > /dev/null 2>&1; then
local unavail_count
unavail_count=$(run_with_timeout 2 xcrun simctl list devices unavailable 2> /dev/null | command awk '/\([0-9A-F-]{36}\)/ { count++ } END { print count+0 }')
local unavailable_devices_output=""

# Tests may mock xcrun as a shell function. Timeout wrappers execute
# in a separate process and cannot reliably invoke exported functions.
# Prefer direct function invocation in that case.
if declare -F xcrun > /dev/null 2>&1; then
unavailable_devices_output=$(xcrun simctl list devices unavailable 2> /dev/null || true)
else
unavailable_devices_output=$(run_with_timeout 2 xcrun simctl list devices unavailable 2> /dev/null || true)
if [[ -z "$unavailable_devices_output" ]]; then
unavailable_devices_output=$(xcrun simctl list devices unavailable 2> /dev/null || true)
fi
fi
unavail_count=$(printf '%s\n' "$unavailable_devices_output" | command awk '/\([0-9A-F-]{36}\)/ { count++ } END { print count+0 }')
[[ "$unavail_count" =~ ^[0-9]+$ ]] || unavail_count=0
if [[ "$unavail_count" -gt 0 ]]; then
if [[ "${DRY_RUN:-false}" == "true" ]]; then
Expand Down
12 changes: 11 additions & 1 deletion lib/clean/dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,17 @@ clean_dev_mobile() {

# Check if simctl is accessible and working; timeout prevents hang when CLT-only.
local simctl_available=true
if ! run_with_timeout 2 xcrun simctl list devices > /dev/null 2>&1; then
local simctl_probe_ok=false
if declare -F xcrun > /dev/null 2>&1; then
if xcrun simctl list devices > /dev/null 2>&1; then
simctl_probe_ok=true
fi
else
if run_with_timeout 2 xcrun simctl list devices > /dev/null 2>&1; then
simctl_probe_ok=true
fi
fi
if [[ "$simctl_probe_ok" != "true" ]]; then
debug_log "simctl not accessible or CoreSimulator service not running"
echo -e " ${GRAY}${ICON_WARNING}${NC} Xcode unavailable simulators · simctl not available"
note_activity
Expand Down
10 changes: 10 additions & 0 deletions lib/core/bundle_resolver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ bundle_has_installed_app() {
# - Privileged helpers embedded in a parent .app under
# Contents/Library/LaunchServices/<helper-bundle-id> (e.g. the Adobe
# ARMDC helpers shipped inside Adobe Acrobat DC.app) -- issue #733
local parent_id=""
local suffix
for suffix in ".helper" ".daemon" ".agent" ".xpc"; do
if [[ "$bundle_id" == *"$suffix" ]]; then
parent_id="${bundle_id%"$suffix"}"
break
fi
done

local app_root app info app_bundle
for app_root in "${_MOLE_BUNDLE_RESOLVER_APP_ROOTS[@]}"; do
[[ -d "$app_root" ]] || continue
Expand All @@ -63,6 +72,7 @@ bundle_has_installed_app() {
[[ -f "$info" ]] || continue
app_bundle=$(plutil -extract CFBundleIdentifier raw "$info" 2> /dev/null || echo "")
[[ "$app_bundle" == "$bundle_id" ]] && return 0
[[ -n "$parent_id" && "$app_bundle" == "$parent_id" ]] && return 0
done < <(find "$app_root" -maxdepth 1 -name "*.app" -print0 2> /dev/null)
done

Expand Down
33 changes: 33 additions & 0 deletions tests/bundle_resolver.bats
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,39 @@ EOF
[ "$status" -ne 0 ]
}

@test "bundle_has_installed_app finds parent app via .helper suffix (issue #753)" {
make_app "$FAKE_APPS/AlDente Pro.app" "com.apphousekitchen.aldente-pro"

run env FAKE_APPS="$FAKE_APPS" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<EOF
$(prelude)
bundle_has_installed_app "com.apphousekitchen.aldente-pro.helper"
EOF

[ "$status" -eq 0 ]
}

@test "bundle_has_installed_app finds parent app via .daemon suffix" {
make_app "$FAKE_APPS/Example.app" "com.example.myapp"

run env FAKE_APPS="$FAKE_APPS" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<EOF
$(prelude)
bundle_has_installed_app "com.example.myapp.daemon"
EOF

[ "$status" -eq 0 ]
}

@test "bundle_has_installed_app returns non-zero for .helper when parent app absent" {
make_app "$FAKE_APPS/Other.app" "com.example.other"

run env FAKE_APPS="$FAKE_APPS" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<EOF
$(prelude)
bundle_has_installed_app "com.apphousekitchen.aldente-pro.helper"
EOF

[ "$status" -ne 0 ]
}

@test "bundle_has_installed_app rejects malformed bundle IDs" {
run env FAKE_APPS="$FAKE_APPS" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<EOF
$(prelude)
Expand Down
Loading