Skip to content

Improve device handling with fallback support and comprehensive tests#209

Open
trmquang93 wants to merge 4 commits intosweetpad-dev:mainfrom
trmquang93:fix-device-handling-improvements
Open

Improve device handling with fallback support and comprehensive tests#209
trmquang93 wants to merge 4 commits intosweetpad-dev:mainfrom
trmquang93:fix-device-handling-improvements

Conversation

@trmquang93
Copy link

Summary

This PR enhances device handling in SweetPad to better support both modern (iOS 17+) and legacy devices (iOS 16 and below).

Changes

Device Type Improvements (src/devices/types.ts)

  • Added safe defaults for missing device fields (name, OS version, UDID)
  • Added devicectlId property to distinguish between xcodebuild UDID and devicectl identifier
  • Added supportsDevicectl property to check if device supports devicectl (iOS 17+)
  • Graceful handling of "Unknown" OS versions in device labels

Device Manager Enhancements (src/devices/manager.ts)

  • Fetch devices from both devicectl and xcdevice in parallel
  • Create lookup maps for OS version, UDID, and name fallbacks
  • Filter out devices without required fields
  • Enrich device data with fallback values from xcdevice when devicectl returns incomplete data

New Utilities (src/devices/utils.ts)

  • supportsDevicectl() function to check if OS version requires devicectl

New xcdevice Module (src/common/xcode/xcdevice.ts)

  • Query device information from Xcode's xcdevice tool
  • Lookup functions for OS version, UDID, and device name by product type
  • Useful for older devices that don't provide complete information via devicectl

New ios-deploy Module (src/common/xcode/ios-deploy.ts)

  • Support for deploying to iOS < 17 devices using ios-deploy tool

Test Coverage

  • Added comprehensive tests for device management
  • Added test fixtures with real-world devicectl output samples:
    • iOS 17 modern devices
    • iOS 16 devices with missing fields
    • Multiple devices scenarios
    • Invalid/malformed device data
  • Tests for xcdevice parsing and lookup functions
  • Tests for utility functions

Testing

The changes have been tested with various device configurations including:

  • iOS 17+ devices with complete devicectl data
  • iOS 16 devices with incomplete devicectl data
  • Devices missing name, OS version, or UDID fields

Backward Compatibility

These changes are backward compatible. Existing functionality is preserved while adding fallback support for edge cases with older devices.

…ests

This PR enhances device handling in SweetPad to better support both modern (iOS 17+)
and legacy devices:

- Enhanced device type definitions with safe defaults for missing fields
- Added fallback lookups using xcdevice for devices with incomplete devicectl data
- Added deviceUtils module for OS version comparison utilities
- Created xcdevice module to query device info from Xcode's xcdevice tool
- Created ios-deploy module for deploying to iOS < 17 devices
- Added comprehensive test coverage for device management
- Added test fixtures with real-world devicectl output samples
- Gracefully handle missing device name, OS version, and UDID fields

This improves reliability when working with older devices that may not return
complete information through devicectl.
@trmquang93
Copy link
Author

@hyzyla Gentle bump on this PR! 😊

Let me know if you'd like me to make any adjustments or if you need more information. The tests are all green and it should be safe to merge.

@hyzyla
Copy link
Collaborator

hyzyla commented Feb 9, 2026

@trmquang93 I'll try to do my best to check it out this week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments