14

I've recreated a simple app that was originally made in React Native with 5MB file size on the app store. The app has no images or anything of any particular size, but it does use Admob ads.

After uploading it to the app store the build is showing as 35MB...not sure what the reason is but it when opening the package contents of the build archive it seems that a bunch of dylib files in SwiftSupport/iphoneos are created that are very large. that's the biggest folder in the archive anyway. I think it has to do with the Pods folder created in order to use Admob.

I'm guessing it can never be as small as the React Native original app but surely it should not be seven times the size...is there some way to remove the SwiftSupport files or another way to shrink it?

EDIT: Also in the Runner project folder in the build archive in Frameworks there are loads of Swift dylib files in there too that are large. Really all the space is being taken up by these Swift support dylib files...

Just built the app for Android and it's 8.33MB so quite a difference there, even though both versions of course use Admob.

Hasen
  • 11,710
  • 23
  • 77
  • 135
  • you should check this issues for originally flutter GitHub https://github.com/flutter/flutter/issues/16833 – Glamvian Jul 15 '19 at 03:47
  • @Glamvian I don't think that issue is related. The minimum app size is "iPhone X remains at 10.8 MB." so that doesn't explain why my app is 35MB. They also don't mention the SwiftSupport issue which I think is a problem related to Admob. – Hasen Jul 15 '19 at 04:15
  • Did you build the app with the release flag ? – Muldec Jul 15 '19 at 07:58
  • @Muldec Yes of course, and it's already in the app store as a build. – Hasen Jul 15 '19 at 08:44
  • Has anyone managed to create a Flutter app with Admob that does not have all these huge swift dylib files? If so I'd like to know how it was done. – Hasen Jul 15 '19 at 08:53
  • Are you using [admob_flutter](https://pub.dev/packages/admob_flutter#-readme-tab-)? If not, you should try it because it looks like a great library, and it does not look to take up too much space. – Beckett O'Brien Jul 24 '19 at 02:50
  • Yes I'm using admob_flutter... – Hasen Jul 24 '19 at 06:56

2 Answers2

2

This isn't really related to Flutter. Every iOS app containing code that wants to support iOS 11 and lower, needs to contain additional flutter libraries.

You can disable this in Xcode by setting "Always Embed Swift Standard Libraries" to false, and raising the deployment target to iOS 12.

Example of my flutter app with respect to different deployment targets. There is no change in build setting but deployment target only. iOS 13 does not include swift libraries with the build.

iOS version -> App build size 
10 -> 127.8 MB
11 -> 127.8 MB
12 -> 90.9 MB 
13 -> 49.6 MB
GameLoading
  • 6,688
  • 2
  • 33
  • 57
szotp
  • 2,472
  • 1
  • 18
  • 21
  • This is actually not correct, my Apps are all encoded with Objective C only but are still WAY bigger than Android, it's nothing to do with Swift. This has actually already been acknowledged as a bug by the Flutter developers and they're looking into it. There have even been cases as extreme as 7.9MB for the Android version and 62.3MB for iOS for the exact same app exported from Flutter on the App stores. No ads used either... – Hasen Sep 17 '19 at 09:07
  • If your app contains SwiftSupport directory then the flag I mentioned must have been enabled. There is no point in adding swift standard libraries if you don't have any Swift code. Check your plugins. – szotp Sep 17 '19 at 12:53
1

I have two sources: first [1] is titled 'Flutter vs Swift' and second [2] 'How to enable swift support for existing project in flutter'. Reading the both we observe flutter and swift do not have to co-exist and observing the latter we can see how it is enabled with a flag when creating the IOS package. I would first check that IOS folder is created without swift reference.

Third link [3] shows that Admob usage can be done in dart only.

About size, I am not sure though if using dart and disabling Swift would 100% make the trick. Flutter vs Swift link [1] has a native Swift app and 'comparison' equal Flutter app and conclusion was the size of flutter app was doubled about that of Swift app. And sizes where around 20 and 50 MB respectively, Flutter being the biggest.

Edit

It shows up the Swift is part of the plugin / module you use and thus cannot be easily just removed. About the size, Flutter app is normally already bigger than app with Swift and now the solution combines the both. Rise in size is as espected.

[1] https://blog.codemagic.io/flutter-vs-swift/

[2] How to enable Swift support for existing project in flutter

[3] https://flutterawesome.com/easily-implement-ads-into-a-flutter-app/

mico
  • 12,730
  • 12
  • 59
  • 99
  • I followed this https://stackoverflow.com/questions/56987132/flutter-admob-package-stops-my-app-from-building to install my Admob. Do you think any of the steps in that answer lead to Swift support being unnecessarily added? – Hasen Jul 15 '19 at 10:52
  • You had to add some Swift code in there. So most probably, the admob plugin depends on Swift. I found https://github.com/flutter/plugins/tree/master/packages/firebase_admob about fire base admob version, but it needs Firebase and may take some overhead, too. – mico Jul 15 '19 at 11:31
  • I added some swift code? I just altered the Pod file is all...why would that add all those swift support files? – Hasen Jul 15 '19 at 13:11
  • Well, you only added Swift version, anyways that implies the project has Swift involved. Otherwise such setting is pointless. It is part of the plugin you use, so props are you cannot just take it away in any way. – mico Jul 15 '19 at 14:18
  • Isn't the Swift version always set in XCode? It has to be set to *something*..? I just checked a newly made basic fluttter app and it's set to Swift 4 in the xcode project. When I set up Admob for my other app all I did was change it to Swift 4.1. – Hasen Jul 15 '19 at 14:25
  • Is it something in the Pod file? Perhaps `use_frameworks` ? – Hasen Jul 15 '19 at 14:39
  • `firebase_admob` requires creation of a firebase project...something not mentioned in the install instructions. In any case it seems it's for apps already using firebase and no doubt would result in a huge app, probably even bigger than it is with the `admob_flutter` I'm using at the moment... – Hasen Jul 16 '19 at 09:06