Skip to content

Commit 139c499

Browse files
abueideclaude
andauthored
feat(segkit): add doctor command with Homebrew/applesimutils auto-install (#71)
* feat(segkit): add doctor command with --fix for auto-remediation Replaces `segkit setup` with `segkit doctor` / `segkit doctor --fix`. Doctor checks for devbox, Homebrew, and applesimutils, and --fix auto-installs anything missing. Also adds Homebrew bin dirs to PATH during iOS plugin init so applesimutils is discoverable in --pure mode. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat(ios): run segkit doctor --fix in init hook Ensures Homebrew and applesimutils are installed on first devbox shell entry. Subsequent runs are a no-op since deps are already present. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(ios): only shim specific Homebrew binaries, not entire bin dir Symlinks only the tools we need (applesimutils) into a private brew-shims dir rather than adding all of /opt/homebrew/bin to PATH. Prevents Homebrew-installed node/python/etc from shadowing Nix packages. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(segkit): silent no-op when deps OK, clear message when fixed Doctor --fix now produces no output when all dependencies are present (silent no-op for init hook). When something is installed, prints what was fixed and asks the user to retry their command. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(segkit): exit 0 on successful fix, print progress during installs Doctor now prints "segkit: installing X..." before each install so users know what's happening and can cancel if needed. Exits SUCCESS when deps are fixed (init hook continues). Silent no-op when all deps are already present. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: update devbox.lock files with segkit flake resolution Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style(segkit): apply cargo fmt formatting Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e19d46c commit 139c499

10 files changed

Lines changed: 374 additions & 67 deletions

File tree

examples/ios/devbox.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,10 @@
393393
"last_modified": "2026-02-15T17:45:47Z",
394394
"resolved": "github:NixOS/nixpkgs/ac055f38c798b0d87695240c7b761b82fc7e5bc2?lastModified=1771177547"
395395
},
396+
"github:segment-integrations/mobile-devtools?dir=segkit&ref=main": {
397+
"last_modified": "2026-05-08T18:52:56Z",
398+
"resolved": "github:segment-integrations/mobile-devtools/725aff9a75fa0ae7269f0f6dbf36fa5611b0664c?dir=segkit&lastModified=1778266376"
399+
},
396400
"gnugrep@latest": {
397401
"last_modified": "2026-01-23T17:20:52Z",
398402
"resolved": "github:NixOS/nixpkgs/a1bab9e494f5f4939442a57a58d0449a109593fe#gnugrep",

examples/react-native/devbox.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,10 @@
517517
"last_modified": "2026-02-15T17:45:47Z",
518518
"resolved": "github:NixOS/nixpkgs/ac055f38c798b0d87695240c7b761b82fc7e5bc2?lastModified=1771177547"
519519
},
520+
"github:segment-integrations/mobile-devtools?dir=segkit&ref=main": {
521+
"last_modified": "2026-05-08T18:52:56Z",
522+
"resolved": "github:segment-integrations/mobile-devtools/725aff9a75fa0ae7269f0f6dbf36fa5611b0664c?dir=segkit&lastModified=1778266376"
523+
},
520524
"gnugrep@latest": {
521525
"last_modified": "2026-01-23T17:20:52Z",
522526
"resolved": "github:NixOS/nixpkgs/a1bab9e494f5f4939442a57a58d0449a109593fe#gnugrep",

plugins/ios/virtenv/scripts/init/doctor.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,15 @@ else
4444
DOCTOR_CHECKS_PASSED=$((DOCTOR_CHECKS_PASSED + 1))
4545
fi
4646

47-
# Check 3: Device lock file
47+
# Check 3: applesimutils (required for Detox iOS testing)
48+
if command -v applesimutils >/dev/null 2>&1; then
49+
DOCTOR_CHECKS_PASSED=$((DOCTOR_CHECKS_PASSED + 1))
50+
else
51+
issues+=("applesimutils not installed (run: segkit setup)")
52+
DOCTOR_CHECKS_WARNED=$((DOCTOR_CHECKS_WARNED + 1))
53+
fi
54+
55+
# Check 4: Device lock file
4856
config_dir=$(doctor_resolve_config_dir 2>/dev/null || echo "${IOS_CONFIG_DIR:-./devbox.d/ios}")
4957
devices_dir="${IOS_DEVICES_DIR:-${config_dir}/devices}"
5058
lock_file="${devices_dir}/devices.lock"

plugins/ios/virtenv/scripts/init/init-hook.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ if [ "$(uname -s)" != "Darwin" ]; then
1515
exit 0
1616
fi
1717

18+
# Ensure iOS dependencies (Homebrew, applesimutils) are installed
19+
if command -v segkit >/dev/null 2>&1; then
20+
segkit doctor --fix || true
21+
fi
22+
1823
# Find virtenv directory
1924
VIRTENV_DIR="${IOS_SCRIPTS_DIR:-}/.."
2025
if [ -z "$VIRTENV_DIR" ] || [ "$VIRTENV_DIR" = "/.." ]; then

plugins/ios/virtenv/scripts/platform/core.sh

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,28 @@ ios_setup_native_toolchain() {
212212
done
213213
IFS="$_ntc_oifs"
214214

215-
# Prepend Xcode and system tool paths
215+
# Prepend Xcode, system, and Homebrew tool paths
216216
PATH="/usr/bin:/bin:/usr/sbin:/sbin"
217217
if [ -n "${DEVELOPER_DIR:-}" ]; then
218218
PATH="$DEVELOPER_DIR/usr/bin:$PATH"
219219
fi
220+
# Add specific Homebrew-installed tools needed for iOS development.
221+
# We symlink individual binaries into a private dir rather than adding
222+
# all of /opt/homebrew/bin, to avoid conflicts with user-installed
223+
# packages (e.g. node via Homebrew shadowing the Nix-provided one).
224+
_ntc_brew_shims="${IOS_SCRIPTS_DIR:-/tmp}/../brew-shims"
225+
mkdir -p "$_ntc_brew_shims" 2>/dev/null || true
226+
for _ntc_tool in applesimutils; do
227+
for _ntc_brew_dir in /opt/homebrew/bin /usr/local/bin; do
228+
if [ -x "$_ntc_brew_dir/$_ntc_tool" ] && [ ! -e "$_ntc_brew_shims/$_ntc_tool" ]; then
229+
ln -sf "$_ntc_brew_dir/$_ntc_tool" "$_ntc_brew_shims/$_ntc_tool" 2>/dev/null || true
230+
break
231+
fi
232+
done
233+
done
234+
if [ -d "$_ntc_brew_shims" ]; then
235+
PATH="$PATH:$_ntc_brew_shims"
236+
fi
220237
PATH="$PATH:$_ntc_clean"
221238
export PATH
222239
fi

plugins/ios/virtenv/scripts/user/doctor.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,13 @@ doctor_check_command "xcodebuild" "xcodebuild" "false"
9595
doctor_check_command "xcbeautify" "xcbeautify (for pretty build output)" "false"
9696
doctor_check_command "pod" "CocoaPods" "false"
9797

98+
# applesimutils (required for Detox iOS testing)
99+
if command -v applesimutils >/dev/null 2>&1; then
100+
doctor_check_pass "applesimutils (for Detox iOS testing)"
101+
else
102+
doctor_check_warn "applesimutils" "Not installed. Run: segkit setup"
103+
fi
104+
98105
# Check jq (needed for config operations)
99106
doctor_check_command "jq" "jq (for config operations)" "false"
100107

0 commit comments

Comments
 (0)