Skip to content

Run a virtual iPhone on an Apple Silicon Mac.

Swift

Stage the terminal's resource bundle where Bundle.module looks

Lakr8932a6336386
diff --git a/VPhoneExecutable/VPhoneVirtualization/Build/StageBundle.sh b/VPhoneExecutable/VPhoneVirtualization/Build/StageBundle.sh
index 5928ee8e..fe380319 100755
--- a/VPhoneExecutable/VPhoneVirtualization/Build/StageBundle.sh
+++ b/VPhoneExecutable/VPhoneVirtualization/Build/StageBundle.sh
@@ -66,10 +66,12 @@ fi
/bin/cp "$TARGET_BUILD_DIR/vphone-vm" "$macos/vphone-vm"
# The terminal window's resources. libghostty is a static library, so nothing
# is embedded for it, but GhosttyTerminal reads its Ghostty directory and its
-# compiled terminfo through Bundle.module, which looks beside the executable.
-# Without this the window traps the moment a session is opened.
+# compiled terminfo through Bundle.module. That searches Bundle.main's
+# resources and then its root, and for vphone-vm Bundle.main is VPhone.bundle,
+# not Contents/MacOS, so a copy beside the executable is never found. Without
+# this the window traps the moment a session is opened.
/bin/cp -R "$TARGET_BUILD_DIR/GhosttyKit_GhosttyTerminal.bundle" \
- "$macos/GhosttyKit_GhosttyTerminal.bundle"
+ "$resources/GhosttyKit_GhosttyTerminal.bundle"
/bin/cp "$command_products/vphone-cli" "$macos/vphone-cli"
/bin/cp "$amfi_products/vphone-escalator" "$macos/vphone-escalator"
/bin/cp "$daemon_products/vphoned" "$guest/vphoned"
@@ -193,10 +195,6 @@ compatibility_library="$(/usr/bin/xcrun swift-stdlib-tool --print \
/bin/rm -f "$frameworks/libswiftCompatibilitySpan.dylib"
/usr/bin/codesign --force --sign - "$frameworks/VPhonePatchKit.framework"
-# A nested bundle is a subcomponent of the outer seal whether or not it holds
-# any code, so this one is signed too; without it the bundle cannot be sealed
-# at all.
-/usr/bin/codesign --force --sign - "$macos/GhosttyKit_GhosttyTerminal.bundle"
/usr/bin/codesign --force --sign - "$macos/vphone-cli"
/usr/bin/codesign --force --sign - --entitlements "$root/VPhoneDaemon/Configuration/VPhoneDaemon.entitlements" "$guest/vphoned"
/usr/bin/codesign --force --sign - --entitlements "$root/VPhoneDaemon/Configuration/VPhoneDaemon.entitlements" "$guest/vphoned-tvos"
diff --git a/VPhoneExecutable/VPhoneVirtualization/Build/ValidateBundle.sh b/VPhoneExecutable/VPhoneVirtualization/Build/ValidateBundle.sh
index a51e1406..579a001b 100755
--- a/VPhoneExecutable/VPhoneVirtualization/Build/ValidateBundle.sh
+++ b/VPhoneExecutable/VPhoneVirtualization/Build/ValidateBundle.sh
@@ -42,13 +42,14 @@ for name in vphone-vm vphone-cli vphone-escalator libswiftCompatibilitySpan.vpho
require_signed_macho "$macos/$name"
done
require_signed_macho "$frameworks/VPhonePatchKit.framework/Versions/A/VPhonePatchKit"
-# The terminal reads these through Bundle.module, which searches beside the
-# executable and traps when it finds nothing. A missing resource bundle is
-# therefore not a degraded terminal but a crash on opening one, and it carries
-# no Mach-O, so no other check here would notice it had gone.
+# The terminal reads these through Bundle.module, which searches
+# VPhone.bundle's Contents/Resources and root, never Contents/MacOS, and traps
+# when it finds nothing. A missing or misplaced resource bundle is therefore
+# not a degraded terminal but a crash on opening one, and it carries no
+# Mach-O, so no other check here would notice it had gone.
for name in Ghostty terminfo; do
- [[ -d "$macos/GhosttyKit_GhosttyTerminal.bundle/Contents/Resources/$name" ]] || {
- print -u2 "The Ghostty resource bundle beside vphone-vm has no $name directory"
+ [[ -d "$resources/GhosttyKit_GhosttyTerminal.bundle/Contents/Resources/$name" ]] || {
+ print -u2 "The Ghostty resource bundle in Contents/Resources has no $name directory"
exit 1
}
done