Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Flutter's kernel_blob.bin?

Tags:

flutter

Every time I do flutter build, I get a file change in

ios/Flutter/flutter_assets/kernel_blob.bin

After committing and rebuilding then I get a lot of conflicts because of this file.

What is this file? Should I .gitignore this?

like image 212
Inquisitor K Avatar asked Nov 19 '18 05:11

Inquisitor K


1 Answers

The short answer is that this file is a Dart kernel bytecode representation of your app's code generated by a compiler in Flutter's toolchain. When your Dart code changes, you should expect the built kernel_blob.bin to also change.

In a bit more detail, the flutter tool is responsible for managing the build pipeline for your Flutter app. Since your example is an iOS example, I'll describe an iOS build. During a compile via flutter build, the tool does the following:

  1. Compile source to Dart kernel bytecode: the flutter tool locates your app's main entry point (by default lib/main.dart) and hands it to the Dart kernel compiler. The kernel compiler traverses the import graph, and emits kernel bytecode to kernel_blob.bin.
  2. Compile kernel to ARM assembly: In AOT builds (profile or release mode), the kernel bytecode is then handed to the gen_snapshot tool, which on iOS emits ARM assembly code (we do this twice, once for 32-bit and once for 64-bit).
  3. Compile assembly to an iOS framework: The assembly code for each bitness is compiled into an iOS shared library (.dylib file) using the clang compiler. We then use lipo (part of Xcode's toolchain) to merge the two .dylibs into a universal binary and wrap it up as a framework, including verison info, Info.plist, etc. This is emitted as App.framework.
  4. Generate the iOS .app bundle: The native bits of your app are compiled into an iOS .app bundle. Both App.framework (your app) and Flutter.framework (the Flutter engine/runtime) are bundled into the app's frameworks directory.
  5. Install the app to the device: The .app file is installed to the connected device and optionally launched.

You should ignore this file (and the rest of the build directory) in your .gitignore.

like image 195
cbracken Avatar answered Nov 12 '22 12:11

cbracken