Compile times and run times concept

Viewed 112

I am trying to understand behind the scenes periods when writing codes to clicking on iPhone Screen. I made some enumerations to make question clear.

Time 1: I am writing codes on Xcode ( compile time )


Time 2: There is a syntax error or I forgot the override keyword ( compiler works on behind the scene and say hey you have an error, fix this)


Time 3: I fixed the error, looks like there is no error. ( compile time )


Time 4: I pushed the Command + B and no error ( compile time - swift compiler converted my front end code to assembly code for my CPU and RAM


Time 5: Command R ( Run time )


Time 6: My app works fine. ( Run time )

Rather than pointing stack on compile time and heap on run time ( value types on stack - reference types on heap ) ,

  • Could you explain me what happens in these time periods which I enumerated ? For example at the Time 3 - compile time. My machine or program know where String values or my custom methods ( value types ) knows where they will be put in memory exactly ? Yes it will be allocated in stack but as soon as I wrote code swift compiler convert to machine code and putting to the RAM stack side or I have some missing point ?

  • My second question which is related to first one, in Run time all value types memory allocated for stack ?

I almost read all resources so I have some background but I could not imagine what is going on exactly when I divide this time slots. Thanks

1 Answers

Just to resume a little : Time 1 to Time 3 are editor time. What happens there is that the compiler is run only to check for syntax, variable initialization, parameters validity,... This is just ´precompilation’

Time 4 is compile time where machine code is generated, link who’s all needed libraries and frameworks.

Time 5 is installation, start (eventually debugger connection to running process)

Time 6 is application is running and interacting with user

Related