Support Runtime Code Injection

Originator:orta.therox
Number:rdar://26878132 Date Originated:18-Jun-2016 09:14 AM
Status:Closed Resolved:
Product:Developer Tools Product Version:10.12 / XC8
Classification: Reproducible:
 
Over time the iteration cycle on an application has taken longer. 

Adopting modern technologies like Swift can make your apps run faster, but at the trade-off of developer iteration time as compiles can take longer. On top of that, when building an iOS application, you need to close your application and replace it with the new build to validate your changes.

All this time, comes up to roughly 6-10 seconds per iteration on a default iOS template project. Even when doing an incremental build.

--

For the last 4 years - there has been 2 Xcode plugins called Injection for Xcode, and DyCI that provide a way to iterate faster on your applications.

https://github.com/johnno1962/injectionforxcode
https://github.com/DyCI/dyci-main

If you'd like a quick overview of how this works, and a few videos examples. You can find a 15m video I authored showcasing Injection for Xcode here: http://artsy.github.io/blog/2016/03/05/iOS-Code-Injection/

Injection allows me to rapidly build out view controllers and business logic in an elegant way, iteration times go down from seconds to microseconds. I can recieve a notification in my app that injection has occured and I then re-create the development state.

Obviously the Xcode plugins are based on clever hacks, but they work. With Swift too. For contrast, in the Android world, this is considered a key feature of their development environment:

http://android-developers.blogspot.com/2016/04/android-studio-2-0.html

> Instant Run - For every developer who loves faster build speeds. Make changes and see them appear live in your running app. With many build/run accelerations ranging from VM hot swapping to warm swapping app resources, Instant Run will save you time every day.

https://developer.android.com/studio/run/index.html#instant-run

A quick look over their official dev page shows that Android Studio supports a few types of injection methods, hot swap, warm swap and cold swap - depending on the complexity of the changes. As iOS also has the same process model ( I think ) similar options could be available for developers using Xcode.

This technique of saves me so much time, makes it significantly easier to work on building new application functionality that I'd love to see it being taken on officially within Xcode.

--

Currently in order to continue using Xcode plugins you either have to use Xcode 7, unsign Xcode 8, or disable SIP entirely. For me, that is worth the tradeoff of keeping a 0.5 second iteration time. 

At least until I can get a separate Mac app to do the Injection work.

Comments

Closed as dupe

7862272

By orta.therox at June 23, 2016, 12:01 p.m. (reply...)

I added an extra comment:

When I opened this up for comments on both open radar, and twitter - I got some interesting feedback.

https://twitter.com/orta/status/744202120941887489 https://openradar.appspot.com/radar?id=5003150729674752

Given that I won't be around for any internal discussion I want to make a few things certain.

This is not a request to remove SIP, or to expand the extension API so that it could be feasible to pull this off as a plugin. I'm not sure you could do that in a way that would fit well with how app extensions could work.

I know about Fix and Continue, but I don't have any first-hand knowledge of how it works. This could indeed be a request for this to come back as a feature, I'm not exactly sure there.

Turns out Visual Studio also has the feature. I don't know too much about the windows dev world.

By orta.therox at June 18, 2016, 7:56 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!