2

I would like to add several extensions into my iOS application but it seems that once I do, I quickly exceed the 100Mb limit that Apple places on Over-The-Air downloads.

  • com.apple.usernotifications.content-extension
  • com.apple.usernotifications.service
  • com.apple.ui-services
  • Document picker extensions

Each bare bones extension results in a 6Mb addition to my application.

Since the Xamarin runtime is presumably embedded into each instance, is there any way I can share this runtime among the various extensions?

Is this available as a mtouch compiler flag?

What other options do I have?

Right now I'm asked to add 11 Extensions, and I'm already at 70MB and I haven't even started coding or adding assets yet.

SushiHangover
  • 73,120
  • 10
  • 106
  • 165
makerofthings7
  • 60,103
  • 53
  • 215
  • 448
  • Each `.appex` is an independent app that basically runs in its own sandbox and are launched as an independent process every time they are invoked. So even if the same extension is launched by different apps, they do not share the same memory addressing space and thus a shared runtime among multiple extensions from the same host app is not possible. Personally I would look at do you really need 11 separate exts? Do any of them not use a extension context to communicate to the host app and thus available to be move to a separate host app, etc... – SushiHangover Dec 03 '16 at 20:15

1 Answers1

4

The most important rule about reducing app size for Xamarin.iOS is still valid:

Enable the managed linker for all assemblies (and all extensions).

Additionally Xamarin.iOS will automatically create a single embedded framework for the Mono runtime which will be used by the app and all extensions (you can check this by verifying that yourapp.app/Frameworks/Mono.framework exists).

Also make sure you don't set the deployment target to anything lower than 8.0 (for the main app) unless you really need it (because if you set the deployment target to anything below 8.0 we have to embed the Mono runtime into the main executable, because iOS 7 does not support embedded frameworks).

Unfortunately we're currently not able to share any of the AOT-compiled code from the base class libraries (nor your own code), so for instance mscorlib.dll (and all the AOT-compiled native code) is included both the app and every extension, but this will change in a future release (I'm implementing it right now).

Rolf Bjarne Kvinge
  • 19,253
  • 2
  • 42
  • 86
  • When will the AOT sharing go live? – kspearrin May 05 '17 at 03:00
  • Great, with the update does it just happen automatically or do I need to enable some setting? Any docs on it? – kspearrin May 05 '17 at 11:36
  • Hmm. Installed XI 10.10 from the beta channel and am not seeing any code sharing improvements in the generated ipa. See https://pastebin.com/1ZxrAqVe . Same app size as well. Is there some setting for this I have to enable in the config? Code repo for reference: https://github.com/bitwarden/mobile – kspearrin May 05 '17 at 13:59
  • @kspearrin: please pastebin the complete build log as well, there will be warnings explaining why if code sharing couldn't be done. – Rolf Bjarne Kvinge May 11 '17 at 12:04
  • Please see: https://gist.githubusercontent.com/kspearrin/75742977e81b12420273e9f8f2a8ef42/raw/eb6fe4ebe431798d6860c1e1a0618e864f751106/ios%2520app%2520store%2520build2. I notice the following: `Native code sharing has been disabled for the extension 'BitwardeniOSExtension' because the container app is referencing the assembly 'Google.Analytics' from '.../mobile/src/iOS/obj/iPhone/AppStore/XbdMerge/Google.Analytics.dll', while the extension references it from '.../mobile/src/iOS.Extension/obj/iPhone/AppStore/XbdMerge/Google.Analytics.dll'.` Not sure how to resolve that... Ideas? – kspearrin May 13 '17 at 15:15