Repository navigation
Releases
Releases · tornikegomareli/swapify
swapify 0.5.0
Added
swapify eval '<code>'and the MCP toolevalrun Swift inside the running app, once, on the main thread, without a debugger. The code compiles as a file of the app's module, so it can read and change the app's state, open a screen, or call the app's internal functions.instances(of: T.self)gives the live objects of a class, such as a model that only SwiftUI state holds. The result is the code's value, the app's log, and the screen if the code changed it.- Each reload, tap and eval result has the app's log since the last result: its
print,LoggerandNSLoglines, each line once with its count.swapify logand the MCP toollogshow it on demand. - When the app crashes, the next command says how and where: Swift's fatal error or the uncaught exception, and the function, file and line of the app's code. Code that a reload replaced has no line, only its function and file. A crash while the app starts is reported the same way.
- A live reload that changes nothing on screen says so: what the edit changed is not on that screen, or shows only after an action. Before, such a reload looked like any other success.
Fixed
- On an iPhone, a reload of a file with an
@Observableclass failed to link:fixup error (kind=diff32) at 'l_keypath'. A key path to the class's property pointed into the class's descriptor, which a device patch takes from the app. It now goes through a pointer to the app's descriptor, so the key path also equals the app's, and the view keeps observing the model. - On an iPhone, the app's log arrived as one long line: the device's console ends lines with CR LF.
Changed
- The agent protocol is version 4, for
call. An app launched by an earlier swapify needsswapify runagain. - Each launch starts a new
.swapify/console.log.
swapify 0.4.0
Added
- Point and ask. A hand button in the running app, in the simulator, on an iPhone or on the Mac. Tap it, tap the part of the screen that should change, and say or type how. Claude Code gets the request with the element, the code around it and a screenshot, edits the code, and each edit reloads into the app while you watch. The app shows the result.
- In a Claude Code session started with
--dangerously-load-development-channels server:swapify, the MCP server is a channel: each request arrives in the session as a message from swapify, and Claude ends it with the newanswertool. swapify listenruns an agent in print mode for each request instead: Claude Code, or another agent with--agent. The app shows each step.
Changed
- The agent protocol is version 3, for
point-nextandpoint-status. An app launched by an earlier swapify needsswapify runagain.
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 ...
swapify 0.2.0
Added
- macOS apps.
swapify run --macbuilds the macOS app with reload support, opens it on this Mac, and reloads it like a simulator app: SwiftUI views keep their@State, AppKit view controllers build their views again in place,@objcmethods reload, and a new stored property of a class lives beside existing objects.ui,tap,screenshot,watch,doctorand the MCP tools work with it. The Debug build turns off the App Sandbox and the hardened runtime on thexcodebuildcommand line, so the agent can load and listen; the project does not change. macOS scans each new patch before it loads, so a reload costs about 250 ms more than in the simulator. - Examples/Desk, a macOS app with an AppKit list and a SwiftUI detail in a split view, and its end-to-end test,
scripts/e2e-mac.py. - docs/research/spikes/07-macos: what a macOS app needs, measured.
swapify 0.1.4
Added
- UIKit screens refresh after a reload, with no code in the app. Each view controller on screen that the edit touches loads its view again in place, through its own
loadViewandviewDidLoad. The view controller object stays, so its properties, its place in the navigation stack, and the app's data are kept. A view controller off screen loads its view with the new code when it shows again. Views of edited classes lay out and draw again, and table and collection views whose data source or delegate was edited reload their data. A view controller or view that implements@objc func injected()gets that call instead. Therefreshreply counts what was refreshed (uikit). @objcmethods reload: overrides such asviewDidLoad, data source and delegate methods, and actions. Before, UIKit kept calling their old bodies, because it calls them through the Objective-C runtime. In the simulator, a new@objcmethod, such as a new action, reloads too. On an iPhone it needs a rebuild, and the reload says so.tapselects a table or collection view cell, and taps controls that do not respond to accessibility activation, such as a navigation bar's back button.- Examples/Notes, a UIKit app built in code, and its end-to-end test,
scripts/e2e-uikit.py.make e2eruns it after the SwiftUI one.
Fixed
- In an app without SwiftUI,
refreshfailed with "SwiftUI refresh symbols not found", andpingreportedswiftUIRefresh: false.
swapify 0.1.3
Fixed
- In the simulator, the app crashed after a reload of a file with a private type that has a fixed layout, such as a
ViewModifierwithDoublefields: code that named the type's metadata directly got the patch's copy, a second type that SwiftUI could not cast to the app's (#7). Such references now read the app's metadata. Simulator patches compile through LLVM IR for this, about 30 ms more per file. - Every reload failed with
cannot have input files with file liston a target that Xcode compiles through a file list, which large targets get (#6, #8). - A reload failed when the scheme had code coverage on, or when the target emitted localized strings (#8).
- On a target compiled through a file list, the copy of a file as built no longer compiled, so an iPhone reload skipped the layout guard and a new stored property of a class needed a rebuild (#11).
- The app aborted after
swapify runwhen a view had an accessibility element with no frame, such as an emptysafeAreaBar(#9, #10).
swapify 0.1.2
Added
- In the simulator, a stored property added to a class the app was built with reloads instead of asking for a rebuild, for final and non-final classes,
@Observableones too. Objects the app already made keep their layout: the new property lives beside each object, starts at its initial value, and is released with the object. It moves into the object at the next build. A method added to or removed from a non-final class reloads too. Structs, enums, removed, renamed or retyped properties,@Publishedproperties, and every layout change on an iPhone still need a rebuild. The reload says which properties live beside their objects (sideFields), and a refusal names the kind of the type whose layout changed (changedKind).
Fixed
- A class whose superclass changed passed the layout guard when its field count and vtable size stayed the same. It now needs a rebuild.
swapify 0.1.1
Fixed
- On an iPhone, a reload of a file that uses a type created since the build failed with
symbol not found in flat namespace. The files of one patch are now bound together, so the patch keeps the new type's metadata. - A build kept the compile commands of deleted files. A file created again with the same name then compiled with an old command, maybe one for the other platform. Each build now drops them, and such a file borrows a fresh command.
Added
swapify watchreloads Swift files when you save them, for hand edits, for example in Xcode. Start it afterswapify runorswapify run --device; it runs until Ctrl-C. It prints one line for each reload, and--jsonprints each result as one line of JSON.- The README, the agent docs and the skill say that a changed
static letor global constant keeps its old value, and that a computed property reloads.
swapify 0.1.0
The first release: hot reload for coding agents on iOS, in the simulator and on an iPhone.
What it does
swapify runbuilds a Debug app with reload support and launches it in the simulator.swapify run --devicedoes the same on a connected iPhone, without a debugger.- After an edit,
swapify reload, or the Claude Code hook, compiles the Swift files changed since the build and loads them into the running app. The app keeps its screen, its navigation stack and its@State. - New Swift files reload without a rebuild.
- After each reload the agent gets a screenshot and the visible text.
swapify ui,tapandscreenshotlet it read and use the screen. - If an edit does not compile, the app keeps running the last code that compiled, and the agent gets the compiler errors.
- If an edit changes the stored properties of a type the app was built with, or the methods of a class, nothing is loaded, and the agent is told which type changed and to run
swapify run. swapify initadds a Claude Code hook and skill.swapify mcpoffers the same steps to any MCP client (MCP 2026-07-28 and the earlierinitialize-based versions).swapify doctorchecks the Mac, Xcode, the project, the simulator or iPhone, and the running app.
Install
brew tap tornikegomareli/swapify https://github.com/tornikegomareli/swapify
brew install swapifyRequirements
- An Apple silicon Mac and Xcode 26 or later.
- An iOS 26 or later simulator, or an iPhone with iOS 26 or later, Developer Mode on, and a signing team in the project.
- Tested with Xcode 27.2 and iOS 27.2.
Known limits
- Debug builds only.
- UIKit screens do not redraw by themselves; observe the
SwapifyDidReloadnotification to rebuild one. - The app must be in the foreground. On an iPhone, the phone must be unlocked.
- Device mode has been tested on one iPhone with iOS 27.2, over Wi-Fi.