In today’s article, we gonna discuss how Flutter’s build system converts Flutter project with its goods into an iOS application bundle.

We will also let you know the purpose of generated objects so that it can help you to integrate the same processes with your custom build environment.

First Let’s Discuss the Workflow:

When your application is ready to release to make the build process easy you can use Flutter tooling as it helps to make the entire build process easy.

But some of the developers didn’t think this way and they don’t find the process as configurable for their custom build or CI (Continuous Integration) setups.

If you have a custom Xcode build than all the vision added by Flutter tooling is optional and you can configure the build that suits your workflow.

These all information we discuss applies to iOS applications bundles prepared for release to the App Store which means projects built to Flutter’s Release Mode.

To support toolings such as observatory and hot reload profile mode uses a different runtime and packaging model.
Similar App bundle like iOS:

If you want to create similar to a typical iOS app bundle then you can use the flutter build iOS – release command that contains the application executable along with any referenced framework and resources.

What required to compile the Application?

While the installation process starts to install the SDK, at that time flutter tools are cached on into the machine. To check the same you can see under bin/cache directory which is available in the copy of the Flutter SDK.

This directory contains all the versioned tool that is required to work with Flutter so you can integrate any step of the process into your own build system.

Let me introduce to you some of the files that are unique to Flutter’s iOS app bundles – Flutter Engine Framework Bundle:
Flutter.framework directory bundled as an iOS framework bundle, that includes Flutter Engine and Assets that are referenced by the Flutter Engine.

Flutter Engine:

Include core libraries like file, network I/O, file, accessibility, plugin architecture, and support, the Skia renderer and the DartVM.

Assets referenced by Flutter Engine:

This is just ICU data currently.

Ahead-Of-Time Framework Hustle:

An AOT snapshot of all the Dart application code that is written by the user is contained by the App.Framework bundle.

Whenever a release builds, the compiler performs the tree shaking on the Dart code. Hence only the code that is used to end up in the bundle.

The necessary artifacts that are used to create the App.framework bundle are getting generated under machine tool cache by the gen_snapshot.

The Ahead-Of-Time Snapshot:

This library contains the ahead-of-time code that is compiled from Dart to Machine native bits.

The four main symbols contained by the snapshot library that gets generated by gen_snapshot and these symbols can be dumped by nm command.
For example: (for architecture arm64):
00000000004041a0 S _kDartIsolateSnapshotData
0000000000009000 T _kDartIsolateSnapshotInstructions
00000000003fc740 S _kDartVmSnapshotData
0000000000005000 T _kDartVmSnapshotInstructions

The purpose behind the AOT Snapshot:

1. DartVM Snapshot:


This represents the initial state of the Dart heap shared
between isolates.

Helps to launch Dart isolates faster but it doesn’t contain any isolate-specific information.

2. DartVM Instructions:


Have all AOT instructions for common routines.

This information gets shared between all Dart isolates in the VM.

Extremely small snapshot and also contains stubs.

3. Isolate Snapshot:


The initial state of Dart heap represents by these.

Also includes isolate-specific information

4. Isolate Instructions:


Have the AOT code that gets executed by the Dart isolate.

Flutter tools make sure that the assets that are referred by the application and its plugin end up in the app bundle.

These can be easily done by just reading the assets that are listed in the project’s pubspec.yaml file.

WRAP UP with some of the Flutter Application Development iOS
app bundle keypoints:

In the native view hierarchy, Flutter view can be used anywhere as all the content rendered by Flutter get combined under this view.

Flutter can be integrated under a custom build system that is independent of Flutter tooling and development machine as well. All these tools are easily available in the bin/cachedirectory of the Flutter SDK.

Author's Bio: 

Manish Patel is a Co-Founder of Concetto Labs, a leading mobile app development company specialized in android and iOS app development. We provide a one stop solution for all IT related services.