Rupert  Beatty

Rupert Beatty


Inject: Hot Reloading for Swift Applications!


Hot reloading workflow helper that enables you to save hours of time each week, regardless if you are using UIKit, AppKit or SwiftUI.

TLDR: A single line of code change allows you to live code UIKit screen:

Read detailed article about this

The heavy lifting is done by the amazing InjectionForXcode. This library is just a thin wrapper to provide the best developer experience possible while requiring minimum effort.

I've been using it for years.

What is hot reloading?

Hot reloading is a technique allowing you to get rid of compiling your whole application and avoiding deploy/restart cycles as much as possible, all while allowing you to edit your running application code and see changes reflected as close as possible to real-time.

This makes you significantly more productive by reducing the time you spend waiting for apps to rebuild, restart, re-navigate to the previous location where you were in the app itself, re-produce the data you need.

This can save you literal hours off development time, each day!

Does it add manual overhead to my workflows?

Once you configured your project initially, it's practically free.

You don’t need to add conditional compilation or remove Inject code from your applications for production, it's already designed to behave as no-op inlined code that will get stripped by LLVM in non-debug builds.

Which means that you can enable it once per view and keep using it for years to come.


Initial project setup

To integrate Inject just add it as SPM dependency:

via Xcode

Open your project, click on File → Swift Packages → Add Package Dependency…, enter the repository url ( and add the package product to your app target.

via SPM package.swift

dependencies: [
      name: "Inject",
      url: "",
      from: "1.0.5"

via Cocoapods Podfile

pod 'Inject'

Individual Developer setup (once per machine)

If anyone in your project wants to use injection, they only need to:

  • You must add "-Xlinker -interposable" (without the double quotes) to the "Other Linker Flags" of all targets in your project for the Debug configuration (qualified by the simulator SDK to avoid complications with bitcode), refer to InjectionForXcode documentation if you run into any issues
  • Download newest version of Xcode Injection from it's GitHub Page
  • Unpack it and place under /Applications
  • Make sure that the Xcode version you are using to compile our projects is under the default location: /Applications/
  • Run the injection application
  • Select open project / open recent from it's menu and pick the right workspace file you are using

After choosing the project in Injection app, launch the app

  • If everything is configured correctly you should see similar log in the console:
💉 InjectionIII connected /Users/merowing/work/SourceryPro/App.xcworkspace
💉 Watching files under /Users/merowing/work/SourceryPro

Workflow integration

You can either add import Inject in individual files in your project or use @_exported import Inject in your project target to have it automatically available in all its files.


Just 2 steps to enable injection in your SwiftUI Views

  • call .enableInjection() at the end of your body definition
  • add @ObserveInjection var inject to your view struct

Remember you don't need to remove this code when you are done, it's NO-OP in production builds.

If you want to see your changes in action, you can enable an optional Animation variable on Inject.animation that will be used when ever new source code is injected into your application.

Inject.animation = .interactiveSpring()

Using Inject is demoed in this example app

UIKit / AppKit

For standard imperative UI frameworks we need a way to clean-up state between code injection phases.

I create the concept of Hosts that work really well in that context, there are 2:

  • Inject.ViewControllerHost
  • Inject.ViewHost

How do we integrate this? We wrap the class we want to iterate on at the parent level, so we don’t modify the class we want to be injecting but we modify the parent callsite.

Eg. If you have a SplitViewController that creates PaneA and PaneB , and you want to iterate on layout/logic code in PaneA, you modify the callsite in SplitViewController:

paneA = Inject.ViewHost(
  PaneAView(whatever: arguments, you: want)

That is all the changes you need to do, your app now allows you to change anything in PaneAView except for its initialiser API and the changes will be almost immediately reflected in your App.

Make sure to call initializer inside Inject.ViewControllerHost(...) or Inject.ViewHost(...). Inject relies on @autoclosure to reload views when hot-reload happens. Example:

let viewController = YourViewController()
rootViewController.pushViewController(Inject.ViewControllerHost(viewController), animated: true)

let viewController = Inject.ViewControllerHost(YourViewController())
rootViewController.pushViewController(viewController, animated: true)

Remember you don't need to remove this code when you are done, it's NO-OP in production builds.

iOS 12

You need to add -weak_framework SwiftUI to Other Linker Flags for iOS 12 to work.

The Composable Architecture

If like myself you love PointFree Composable Architecture, you’d probably want to inject reducer code, this isn’t possible in vanilla TCA because reducer code is a free function which isn’t as straightforward to replace with injection, but our fork at The Browser Company supports it.

Download Details:

Author: krzysztofzablocki
Source Code: 
License: MIT license

#swift #ios #hot #reload #swiftui 

Inject: Hot Reloading for Swift Applications!

Ba altcoin vốn hóa nhỏ có tiềm năng breakout trong mùa altcoin khủng sắp tới

ong một video mới, Van de Poppe nói rằng các altcoin đã sẵn sàng để vượt trội hơn đáng kể so với Bitcoin trong những tuần tới.

“Các loại altcoin đang vượt trội hơn nhiều so với Bitcoin vì Bitcoin rất có thể sẽ tạo ra một phạm vi giới hạn và trong những tháng đó, các loại altcoin sẽ hoạt động tốt”.

Van de Poppe cho biết khi một mùa altcoin khủng tiếp cận và giới hạn Bitcoin, điều quan trọng là phải tìm kiếm các dự án chưa chuyển động.

Ví dụ: Trader đề cập đến giao thức web phân tán Holochain (HOT), giao thức này đã có một sự đột phá lớn vào đầu tháng 4 lên mức cao nhất mọi thời đại là 0,031 đô la.

Trong khi Van de Poppe tin rằng Holo sẽ bùng phát trở lại, anh dự đoán đợt phục hồi thứ hai của nó sẽ xảy ra muộn hơn trong làn sóng mùa altcoin tiếp theo, có thể vào khoảng giữa tháng Sáu.


Ba altcoin vốn hóa nhỏ có tiềm năng breakout trong mùa altcoin khủng sắp tới