yfuruyama / iOSRuntimePreview

iOS runtime tool to execute modified source codes without rebuilding them
https://vimeo.com/87261099
6 stars 0 forks source link

iOS Runtime Preview

This tool allows you to execute modified source codes without rebuilding a running iOS app.

You can check instantly the result of modification to the source code as if you are using an interpreter.
There is no need for compiling again after editing a source code with this tool!

iOSRuntimePreviewDemo

See video: https://vimeo.com/87261099

Install

$ git clone https://github.com/addsict/iOSRuntimePreview.git

Requirements

The target iOS app must be compiled with a option -O0(default option for debug build).

How to use

  1. Run your iOS app from Xcode by either the iOS simulator or the iOS device.

    img1

  2. Pause execution of running app by clicking a pause button at debug area or keyboard shortcut ^⌘Y.

    img2

  3. Import preview.py into a LLDB debug session by below command.
    You may execute this command just one time within same debug session.

    img3

  4. Register a source file which you'll edit in runtime by below command, then clicking a play button at debug area.
    Syntax: preview <file>

    img4

  5. It's all done! You can edit a source code and that modification will be appeared in running app without compiling again.

How it works

The key technique is LLDB breakpoints.
Once you insert a new code into a source file, a breakpoint is set at the line of inserted code and LLDB debugger executes it when debugger hits the breakpoint.
On the other hand, if the code is deleted from a source file, a breakpoint is set again, then LLDB debugger sets the address of next instruction to PC(Program Counter) to skip the deleted code when debugger hits the breakpoint.

Limitation

Currently, there exist some limitations for using this tool.