Skip to content

[Feature] Improve iOS device detection performance: prioritize idb over xcrun #2775

Description

@EmmaYuan1015

Problem Statement

The current iOS device detection logic in iOSContainerUtility.ts performs
unnecessary Xcode environment detection even when idb is available. This adds
latency to device list refresh operations.

Root Cause

The targets() function checks Xcode availability first, then idb availability
in a ternary expression. Since idb is more CPU-efficient than xcrun, we should
prioritize it early to avoid the Xcode detection process when possible.

Solution

Refactor the control flow in targets() function to:

  1. First: Check if idb is available → use it (fast path)
  2. Then: Check if Xcode is installed
  3. Finally: Fall back to idb_companion if Xcode is not installed

Changes

  • Move isIdbAvailable() check before isXcodeDetected()
  • Flatten nested ternary expression into sequential if-else blocks
  • Add explicit comments for each fallback path
  • Remove resolved TODO comment

Performance Impact

  • ✅ Reduces unnecessary process calls on macOS
  • ✅ Faster device list refresh when idb is available
  • ✅ Better code clarity and maintainability

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions