Repository navigation
swapify 0.3.0
Security
- The agent in a simulator or macOS app took commands from any process on the Mac, and from any web page: a browser sends a cross-origin
POSTto127.0.0.1without asking, and the agent skipped the lines it did not know and ran the rest. Such a request could load a library into the app or write a PNG over any file the app can write (#16). Every connection must now start with the token of the launch, as on an iPhone, and anything else closes it. The wire protocol is version 2.
Added
-
The MCP
runtool takestarget(simulator,deviceormac) andudid. Before, an MCP client could only run a project where it ran last, so a new macOS or iPhone project could not start from MCP (#29). -
Examples/Ticker, a macOS app with no window and an embedded framework, and its end-to-end test,
scripts/e2e-mac-headless.py. It never takes the screen or the focus, somake e2enow covers macOS too.make e2e-macruns the test with a window, Examples/Desk.
Changed
- The layout guard runs on the Mac before a patch is linked, on every platform. Before, a simulator or macOS patch was loaded first and checked in the app, so a patch that was then refused had already run
dlopen: its Objective-C categories had replaced methods, and its types were registered (#19, #21). The check in the app stays as a second one. A reload that puts a class's new property in side storage builds one library, not two, and on macOS saves the scan of the first (#28). - A reload compiles the files it is given, and the files changed earlier only when the patch needs them. Before, every reload compiled every file changed since the build, so one large file, edited once, slowed every later reload until the next build (#28).
- Loading a patch takes about 5 ms in the simulator, down from about 55 ms. One call to the Objective-C runtime for the names of the patch's classes took 50 ms of every reload; the agent now reads the patch's class list itself (#28).
swapify run --devicewith Developer Mode off, andswapify screenshot --fullbefore the first run, end with exit code 1. They were reported as usage errors, with exit code 64 and the usage text..swapify/session.jsonhas a new shape: the last build and the last launch are two records, and each launch replaces its record whole. A session of an earlier version reads as none. Runswapify runonce after the update, which the new agent protocol needs in any case.swapify watchscans when the file system reports a save, not four times a second. It follows the folders of a laterswapify run, and says when a file was deleted (#28, #29)..swapify/patcheskeeps the eight newest patches, and a launch empties it. It grew without limit: one run of the end-to-end tests left 560 MB there (#28).- The guard compares a file with the module as it was built, not as it is now. Before, it gave up when the built file no longer compiled against the edited project, for example after a type moved to a new file, and a device then loaded the patch unchecked with a warning (#21). On a device, a file that cannot be checked is no longer loaded.
Fixed
- The MCP
runtool named the simulator of the last launch, so the run failed when that simulator was shut down since. It now takes that simulator if it is still booted, and another one if not, asswapify rundoes. It also checks Developer Mode on the iPhone before the build, not after it. - In the simulator and on macOS, reloaded code got its own copy of a static or global with a constant initial value, such as
static var count = 0: it read 0 again, and what it wrote was lost to the rest of the app. The accessor of such a variable is 12 bytes, and the agent left every accessor under 16 bytes alone, without a word (#24). It now redirects them too, and rejects a patch that it cannot bind to the app. @objcmethods did not reload, and the screen did not refresh, for a view controller or view that is nested in another type, has an Objective-C name of its own (@objc(Name)), or has a name that repeats a word of the module's name. The agent built each class's Objective-C name from the first two parts of its Swift name (#24). It now asks the Swift runtime for the class.- On macOS, edits to a framework embedded in the app did nothing: the agent read the images in
Contents/MacOSonly (#20). A framework that an app loads after launch is now read too. - After about 500 reloads the agent refused more with "too many patches" (#20).
- A patch now takes effect on the app's main thread, between two of its events, with a memory barrier before old code can reach it. Before, the agent's own thread wrote it while the main thread ran (#18).
- A rejected patch leaked its symbol tables, and every image's tables held memory for all of its symbols (#19, #28).
- A view that implements
injected()got the call, and then its view controller built the screen again anyway, which threw the view away (#25). - A rebuilt UIKit or AppKit screen got
viewWillAppearandviewDidAppearagain without the disappear calls first, so an observer or timer started inviewWillAppeardoubled at each reload. On macOS it also got the two appear calls twice: AppKit makes them itself when the new view enters the window (#25). - A reload of a file with a
UIHostingControllerorNSHostingControllersubclass built its view again, which reset the@Stateof its SwiftUI views (#25). - On macOS,
tapon a button in a table row selected the row and did not press the button.uiandtapsaw one window, and never a panel, sheet or popover: now every visible window of the app (#25). - A view whose class name only contains
NSHostingViewor_UIHostingViewwas taken for a SwiftUI hosting view, and a frame that is not a number failed the wholeuireply (#25). - Reloaded code got the patch's own copy of a type, a second type to SwiftUI and to
==, in two more places: a static method of a protocol extension called on a private or fixed-layout type, and a type chosen by a condition,flag ? A.self : B.self(#23). - A device patch kept its own metadata for a type whose
$s…Nalias has a linkage word, and the IR parser trapped on a few malformed inputs (#23). - A new stored property of an
@Observableclass needed a rebuild unless its type was a standard library type:var tag = Tag()orvar tags: [Tag] = []was refused (#22). - A new
weakorunownedproperty of a class was put in side storage as if it were a strong one, which crashed when its object went away. It is refused now, as is a new property of a generic class, with that reason (#22). - A reload with a new method of a class failed to compile when a file called the method both directly, as
super.added()does, and through the vtable (#22). - A subclass in another file went unnoticed when its declaration ran over several lines, and the reload then went ahead (#22).
- A Swift file beside the app's files that is not the app's, such as a test file, failed every reload after its own: it borrowed a build command, did not compile with it, and stayed in every later patch, also after
swapify run. Coding agents edit tests all the time. Such a file is now forgotten when its own compile fails (#26). - A file given through a symlink, or in a project under
/tmpor/var, was taken for a new file and compiled twice (#26). - Two reloads at once, such as the Claude Code hook and
swapify watchon the same save, wrote the session over each other, and the one that started first could load its older code last. One reload, build or launch runs at a time now, across processes (#26). - A compile of a built file that was stopped halfway left a part of a file, which later reloads compared layouts with (#26).
- After a switch between
swapify run,--deviceand--macin one project, files that the new build did not compile kept the other platform's compile commands, and their reloads failed with "incompatible platform" (#27). Each platform's commands are kept apart now. - A run that built for one platform and then failed to launch left the other platform's app running, and reloads tried to load the wrong platform's patches into it (#27). The session records what was built and what runs, and no longer reads either from the app's path.
- A build's macro plugins, compiled for the Mac, counted as reloadable files of an iOS app. A file in the app and in a widget got the command of whichever target compiled last, and a patch compiled as the widget's module replaced nothing (#27).
- A scheme that also builds a helper app or a UI test runner could launch that instead of the app, when it was built last (#27).
- In the simulator and on macOS, a file with a subclass of
UIHostingController, or of another class of a library built for library evolution, could not be reloaded: the check in the app took a pointer in the class's descriptor for a changed size, and said "stored properties changed" for any edit (#21). - In the simulator and on macOS, two methods of a class in another order, a method with another signature, and a property whose type changed to one with the same name in another type or module were not seen as layout changes (#21).
- A type that moved to a new file and changed its layout in the same edit was not guarded on a device (#21).
- A file written while the app was building got a copy "as built" of the text that the build may not have compiled (#21).
swapify runfailed after 20 s for an app with no accessibility elements on its first screen, such as a game view or a menu bar app, though its agent answered (#29).- On macOS,
swapify runlooked for the app's running copy withpgrep -fand the app's path as a pattern: a path with+or(matched nothing or too much, a debugger ortailthat named the path was quit too, and an app that did not quit stayed (#29). It is now found by its executable's path, and killed after 5 s. swapify mcpleft adevicectlin the process table at each run on an iPhone (#29).- When the agent's port was in use on the iPhone, the run waited 40 s and blamed the screen (#29).
swapify initdid nothing for.gitignorewhen.gitis in a folder above the project, and kept the path of a swapify that had moved in the hook and the MCP entry.swapify doctorbuilt the agents in a source checkout, did not check for Xcode 26, and spoke of iOS for a macOS app (#29).- MCP results of legacy requests carried
resultType, and a parse error had noid(#29). - A constant page that the agent wrote to stayed writable, and a failed write to one crashed the app (#18).
- A label of two lines, as SwiftUI gives a
Textwith a line break, was sent as two commands:tapmatched a different element, and the second line ran as a command of its own (#17). - A command longer than 1,088 bytes was cut in two (#17).
- The app ended with
SIGPIPEwhen the CLI went away before it read a reply, andswapify watchandswapify mcpended the same way when the app went away (#17). - After a reply that did not arrive, a device reload sent the same
loadagain on a new connection (#17). - A client that stopped sending, or stopped reading, held the agent for every later command (#17).