Develop iOS Apps Faster… 20x Faster

Saoud M. Rizwan
2 min readFeb 20, 2017

--

Every iOS developer knows the flow — code, build, run on simulator, repeat. Sometimes we end up running a project on the simulator just to make sure that one label is the right font size. And we all know how long it can take for projects to build and run on the simulator — I timed it on my computer (which uses a 3.5 GHz processor) and found that it took about 9 seconds from the time I hit Run to seeing my app on the simulator.

Well not anymore.

Recently I learned about Injection, an app that lets you inject code into the iOS simulator. Don’t be scared, it seems like black magic but it is very easy to use and makes developing apps much, much faster. In fact, with Injection, it takes less than a second to see your updated code running on your app in the simulator. No more re-building and re-running your project, no more mindlessly staring at your screen waiting for your app to show up on the simulator, say goodbye to all that nonsense.

Here’s how you use Injection:

  1. Download the app from the developer’s website. http://johnholdsworth.com/injection.html
  2. After giving Injection all the necessary permissions, you should see a menu bar app show up.
  3. Now create or open up an Xcode project and add this code to your view controller class:
func injected() {

}

4. Build and run your project like you normally would.

5. While the app is running in the simulator, let’s add some code to the injected function:

func injected() {
self.view.backgroundColor = .green
}

5. Save your project and now click on the Injection app icon in the menu bar and then click ‘Inject Source’.

Your view’s background should now be green and your console should be cluttered with a bunch of print logs — that’s normal, it’s Injection letting you know what’s going on in the background.

So what exactly happened?

The code in yourinjected function is added on top of the running project. Xcode didn’t build and run your project again, but rather Injection injected the code in injected into the running app. Kinda cool, right?

Hopefully you can start to see how powerful Injection is and how it can speed up your workflow. Obviously changing your view’s background color is a simple use case, but Injection can be used to inject any sort of code, whether it has to do with the UI or the back end. As long your class is a subclass of NSObject, you can plug in an injected function and use Injection.

I use Injection religiously now and am very grateful to its developer John Holdsworth who undoubtedly put a lot of hard work into it. Check out his github page for more information about Injection and some caveats/workarounds: https://github.com/johnno1962/injectionforxcode

I also made a video about getting started with Injection if you’re interested in seeing it in action:

Let me know if you have any questions!

--

--