19

I am an Android Developer and recently started learning Swift. There is a cool feature in Android studio called Instant Run, that significantly reduce the build and deploy times for incremental code changes during coding.

Introduced in Android Studio 2.0, Instant Run is a behavior for the Run and Debug commands that significantly reduces the time between updates to your app. Although your first build may take longer to complete, Instant Run pushes subsequent updates to your app without building a new APK, so changes are visible much more quickly.

If you enable Instant Run on Android Studio, There is no need to build and run the app from scratch, specially when you are working on some detail View Controller in the middle of the app (storyboard).

I am curious to know if this feature or sth similar is available in XCode or I must run the app from scratch every time I want to test the app?

Milad Faridnia
  • 9,113
  • 13
  • 65
  • 78
  • 1
    Unfortunately that's not (maybe yet) possible. – HAS Mar 01 '17 at 11:39
  • 2
    I hope they add this feature in next versions of xcode ;) – Milad Faridnia Mar 01 '17 at 11:44
  • @HAS The Aashish's answer is somehow close to Instant run feature :D – Milad Faridnia Mar 01 '17 at 12:10
  • 1
    It's kinda but not really ... The initial view controller is what your app starts with, so if in your original flow you pass data from VCA to VCB and then set VCB as the initial view controller, when the app is re-run the data does not get passed to it (because VCA does not get instantiated at all) and you probably can't do much ... – HAS Mar 01 '17 at 12:13
  • I've found a way to use real Instant Run for iOS ! Please read my answer below to see how. – AnthoPak Sep 12 '17 at 13:05

3 Answers3

14

THERE IS A WAY !

I've found this question a while ago, and conclude that there weren't any way to have a real instant run in iOS.

BUT ! I've recently found an awesome lib that allow you to bring to iOS this awesome feature. I share it here because it became essential for me and I would have loved to found it when I came here the first time. It's called Injection for Xcode and it take the form of a plugin. The installation is a little long because of new Xcode limitations. You will have to patch Xcode to be able to run plugins in it. You can find all these informations in the Read Me or in the "Issues". It can take up to 30 minutes, but this plugin is a real time saver !

Once it is installed, run your app as usual with Xcode (CMD + R). Then, change code somewhere in a controller. Now, click CTRL + = to use the Injection plugin. You won't see any reloading in your simulator, but if you try you will see that your code changes has been taken (in a few seconds!).

For example you have this line :

self.view.backgroundColor = [UIColor blackColor];

After your app is running with CMD + R, change the line to :

self.view.backgroundColor = [UIColor whiteColor];

Press CTRL + =, and enjoy !

Hope this helps somebody ! If you have any questions (for installation or other), please ask me in comment.

AnthoPak
  • 4,191
  • 3
  • 23
  • 41
1

You can select the initial - viewController for your project either from the storyboard or programmatically; to the view, which you only need to load at the time for testing.

But, You actually don't need to worry about compiling your code from scratch. This is kind of automate behavior for xCode, as it only compiles your code which you have changed.. You may notice this within your files hierarchy as shown below:-

The 'M' & 'A' at the side of files refers to; 'Modified files' & 'Added files'

The 'M' & 'A' at the side of files refers to; 'Modified files' &

The files without modification; after a build, won't take as much time to build.

Aashish
  • 2,532
  • 2
  • 23
  • 28
1

if you used that SwiftUI use the next option when your device is connected!!!

and press: cmd + s

enter image description here

RAUL QUISPE
  • 800
  • 9
  • 13