fix(ios): extract device UDID by id shape, not column position, in package-ios-zh.sh#14
Open
mvanhorn wants to merge 1 commit into
Open
Conversation
…ckage-ios-zh.sh
The --install path parsed the device id with awk '/connected/{print $(NF-2)}',
counting fields from the end of the row. Any hardware model name with spaces
(e.g. 'iPad Pro 13-inch (M4)') shifted the columns, so it captured a
model-name fragment ('13-inch') instead of the identifier and never reached the
fallback, then failed with 'devicectl device install app --device 13-inch'. The
fallback was also case-sensitive uppercase (devicectl prints lowercase) and
fixed at 36 chars, missing 25-char modern and 40-char legacy UDIDs.
Replace both with a single case-insensitive extraction that matches only valid
identifier shapes (40-char hex, 8-16 modern, 8-4-4-4-12 UUID) on the connected
row, so a multi-word model name can never be mistaken for the id. Match the
state with grep -iw so 'connected' does not also select 'disconnected'.
Fixes ammaarreshi#4
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
scripts/build/ios/package-ios-zh.sh --installnow finds the target device by matching the identifier's shape instead of counting columns, so deploying to a device whose model name contains spaces works.Why this matters
The install path read the device id with
awk '/connected/{print $(NF-2); exit}'— the third field from the end of the row.xcrun devicectl list devicesputs the model name last, so any multi-word model (iPad Pro 13-inch (M4),iPhone 15 Pro Max) shifts the columns and the script captures a fragment like13-inch. Because that's non-empty it never falls through, and install fails withdevicectl device install app --device 13-inch. The fallback was broken two more ways:grep -oE '[0-9A-F-]{36}'is uppercase-only (devicectl prints lowercase) and fixed at 36 chars, so it missed both 25-char modern physical UDIDs (00008020-001234567890ABCD) and 40-char legacy ones. The issue reporter diagnosed this and proposed a shape-matching regex.Changes
Replaced the awk field-count and the broken fallback with one case-insensitive extraction on the connected row:
It matches only valid id shapes (40-char hex, 8-16 modern, 8-4-4-4-12 UUID), so a model-name fragment can't be selected. One refinement over the proposed snippet: the state filter uses
grep -iwsoconnecteddoesn't also matchdisconnected— otherwise a disconnected device's id would be picked and install would target an offline device. The empty-result error path and thedevicectl device installcall are unchanged.Testing
devicectlneeds real hardware, so I verified the extraction against representative fixture rows plusbash -n:bash -n scripts/build/ios/package-ios-zh.sh: passes13-inch)Fixes #4