Instant Run or Hot Reloading for Xcode

I am an Android developer and recently started learning Swift. Android Studio has a cool Instant Run feature that dramatically reduces build and deployment times for incremental code changes during encoding.

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

If you enable Instant Run in Android Studio, there is no need to create and run the application from scratch, especially when you are working on some detailed View Controller in the middle of the application (storyboard).

I am interested to know if this function or a similar version is available in Xcode, or should I start the application from scratch every time I want to test the application?

+5
source share
3 answers

THERE IS A WAY!

I found this question a while ago and came to the conclusion that in iOS there was no real launch of instant start.

BUT! I recently found an awesome library that will let you bring this amazing feature to iOS. I share it here because it has become important to me, and I would love to find it when I came here for the first time. It is called Injection for Xcode and takes the form of a plugin. The installation is a bit long due to the new limitations of Xcode. You will need to fix Xcode in order to be able to run plugins in it. You can find all of this information in Reading Me or Problems. This may take up to 30 minutes, but this plugin is a real-time splash screen !

Once it is installed, launch the application, as usual, using Xcode ( CMD + R ). Then change the code somewhere in the controller. Now press CTRL + = to use the Injection plugin. You will not see any reboot in your simulator, but if you try, you will see that your code changes have been made (in a few seconds!).

For example, you have this line:

 self.view.backgroundColor = [UIColor blackColor]; 

After your application works with CMD + R , change the line to:

 self.view.backgroundColor = [UIColor whiteColor]; 

Press CTRL + = and enjoy!

Hope this helps someone! If you have any questions (for installation or others), please ask me in the comments.

+4
source

You can choose the initial one - viewController for your project either from the storyboard or programmatically; to the view you only need to download for testing.

But . In fact, you do not need to worry about compiling code from scratch. This is a kind of automatic behavior for xCode, as it only compiles your code that you changed. You may notice this in your file hierarchy as shown below: -

"M" and "A" in the file side are related; 'Modified files' & 'Added files'

Files unchanged; After assembly, it won’t take so long to build.

+1
source

Just add more explanation to Aashish's answer:

To achieve this:

Is there a function in xcode that allows me not to start the application from scratch and restart the current view controller during the construction process?

you can set the view controller as the initial view controller

enter image description here

Of course, the HAS comment is absolutely right:

The initial view controller is where your application starts, so if you transfer data from the VCA to the VCB to your original stream, then set VCB as the initial view controller when the application restarts the data, get it (because the VCA does not gets an instance at all) and you probably can't do much

0
source

Source: https://habr.com/ru/post/1264874/


All Articles