The problem
After a certain version of Flutter, we found that the XX. App generated after the Flutter build ios reached an amazing 400 megabytes.
Then try to analyze why it is so large:
flutter build ios --analyze-size
Copy the code
Then I found that the Frameworks had over 380 megabytes in them. When I went inside, I found that they were caused by the files of Flutter.
A search later found that it was because:
Ios’s Flutter binaries have added support for Bitcode, resulting in increased volume.
The specific reasons are:
If we included variants with and without bitcode for iOS, that would even further complicate our variety of binary formats that we produce, leading to more confusion for beginner developers, and larger release archives. We currently have binaries for (static, Swift 2.2, SWIFT 2.3, SWIFT 3.0, SWIFT 3.0.1, SWIFT 3.0.2) all of which could have both variants with/without bitcode.Copy the code
Similar problems exist in other libraries, such as Realm.
When it comes to the App Store, the system automatically strips out the code to make it leaner, which means you don’t end up with an installation file that’s over 4,000 megabytes long, so it’s a waste of upload time. But what if we want to do internal testing, or you want to give your XX. app to a third party to sign what to do, you should know that wechat now only allows you to transfer a maximum of 200M files oh.
So, at this point we can use the xcrun bitcode_strip command to strip the bitcode.
For example, if the package is Runner. App, right-click to display the package contents and go to the Frameworks-Flutter. Framework folder (I prefer terminal, hiahia).
Then run the terminal CD to the Flutter. Framework directory to remove bitcode:
xcrun bitcode_strip Flutter -r -o Flutter
Copy the code
Check again, is Runner. App much smaller?
Supplement knowledge
Post the xcRun bitcode_strip document:
-o output
specifies the output file as output.
-r specifies the bitcode segment is to be removed.
-m specifies the bitcode segment is to be removed and a marker is
left.
-l specifies that only the bitcode segment and the
(__TEXT,__info_plist) section is to be left in the Mach-O file.
Copy the code
The last
Welcome to wechat public account: OpenFlutter