Introduction

In this article, I wanted to show you how to implement an App Clip in a Flutter project based on this document I found while looking into incorporating an App Clip into a Flutter project.

When I finished making the sample app and casually read back the official document while thinking about the structure of the article, I noticed that I overlooked the warning that was written at the beginning of the document.

In the red frame part

Important: This experimental preview currently exceeds the 10MB uncompressed IPA payload size limit and cannot be used in production (# 71098). In
this preview version, the ipa size exceeds the 10MB limit, so it cannot be used in production . (Free translation)

So , at present, it is difficult to make an App Clip with Flutter (it can be made, but
it cannot be published to the App Store) .
Because I made a point early, I couldn’t write what I originally intended to write, so I’ll change my schedule and talk about the current status of Flutter’s App Clip. Excuse me.

How do you include AppClip in your Flutter project?

Before we talk about the current situation, the official documentation will first give you a quick overview of how it is incorporated into your Flutter project.
Basically, it is an operation and support on Xcode. If you narrow down only the important parts and arrange them, it will be as follows.

  1. Add an App Clip target to your Flutter project
  2. The file who were generated in App Clip target Info.plistcapital AppClip.entitlmentto delete all but the
  3. App body of the AppDelegate.swiftarrow LaunchScreen.storyobardto the such as the file of so that it can be referenced from the AppClip target
  4. Added Flutter framewok setting to App Clip target Framework Search Path
  5. Add Flutter Script to Build Script

I have also changed the entitlements settings and build settings, but it looks like this, and in terms of Xcode projects, both the App itself and the App Clip share almost the same resources.
Also, since the code on the dart side cannot be divided for each target, all dart files will be included in both the App itself and App Clip.

At first, I misunderstood that sharing all resources between App and App Clip is the cause of oversize, so if you use the Add to app function for the App Clip target and separate it from the main body, it will work. ?? I thought, but it seems that the cause of the oversize was not that.

Current status of App Clip in Flutter

Can Flutter make App Clips?

Now that we know how to incorporate it into a Flutter project, it’s still difficult to create an App Clip with Flutter. Sorry.

Why is it difficult?

The reason is that, as already mentioned, the ipa of App Clip exceeds the size limit of 10MB of App Clip, so you cannot apply to the App Store. By the way, even the minimal project in the official documentation example seems to already exceed 10MB.
The breakdown of the contents of the App Clip is detailed in Issue here, but the one that is the most squeezing is the Flutter framework, which alone has 7MB. It’s big.
Considering that it includes dart files, image resources, Swift files, etc., it seems difficult to make an App Clip with Flutter unless the Flutter framework fits in about 1MB … 😭

What if I really want to embed an App Clip in my Flutter project?

If you want to create an App Clip in a Flutter project, it seems that there is no choice but to include the Flutter framework in the App Clip target (do not use Flutter) .
Specifically, the app itself must be created in Flutter, and the App Clip must be created natively, such as SwiftUI.
In the issue on Github, the person in Flutter said something similar, so I wonder if Flutter alone is tough at the moment . Shouldn’t the Issue titled
Support app clips on iOS 14 be created natively without using Flutter? I think it is hopeless that the remark is closed at the end. It seems that Flutter will not support App Clip …

Finally

For the time being, there is an issue in Flutter’s issue asking whether it will be possible to divide the code group on the Flutter side for each iOS target, but there is almost no discussion and it seems that hope is weak.

When I tried to explain how to make an App Clip in Flutter, it turned out to be a gag-like article explaining why Flutter couldn’t make an App Clip.
Flutter’s official document is written very carefully, and I am often taken care of when I am in trouble, but I felt that I did not read it unexpectedly even if I thought I was reading the document firmly. It was.
I couldn’t create an App Clip with Flutter, but I can embed an App Clip in the Flutter project itself, and I want to make my app compatible with the App Clip, so let’s create it without fail. I think.