The problem

Where do we start to understand the underlying principles of iOS?

explore

First of all, as iOS developers, we all know that when we create a new project, we will enter the main function first, so we will set a breakpoint here, and then use the console to use bt to view the call stack, as follows:

We notice that the system does something else before main. We can see two calls to start, which is located in the libdyld. Dylib underlying library. Insert _objc_init, libdispatch_init, libSystem_initializer symbol breakpoints as follows:

Once the breakpoint has been set, we can re-run our project and see many other call stacks.

In this way, you can see that the following underlying libraries are involved before the main function.

  1. Libsystem.b.dilib (libSystem_initializer, connect to system libraries)
  2. Dylib (libdispatch_init, system GCD)
  3. Libobjc.a.dylib (_objc_init, underlying Runtime)

found

After entering the main function, we can use the BT directive to see the full picture of which libraries are called by the system.

To explore the underlying principles of iOS, we can start from dyLD to load dynamic libraries, libSystem, classes, categories, protocols, properties, objects, Runtime, Runloop, KVC, kVO, etc.