I'm debating what the right way to do this should be. We could:
- Easy: Mandate that whatever initialization/bootstrapping phase that is setting up the Swift environment also handle extracting the data and placing it in a file somewhere, and then communicate the location by setting an environment variable (like
ICU_DATA_FILE
) thatFoundationICU
will check. While simple, and has the advantage that the data can be stored compressed in the apk's assets, it has the downside of either needing to plop a ~20-~30 MB file onto disk every time the app starts, or else add the complexity of maintaining some checksum and comparing it with a pre-cached file on disk every time initialization takes place. - Hard: Keep the ICU data in the APK and access it using the Asset Manager's support for providing an
mmap
-able file descriptor to the asset contents (which I discuss at Overriding Bundle.module for loading resources from Android assets). The advantage is that we wouldn't need to write a file to disk on every app startup (which reportedly caused issues for Flutter apps in the past when they used this technique), but the disadvantage is that the file couldn't be stored compressed in the APK. Plus, in order to get a handle to the NDKAAssetManager
, you need ajobject
pointer to the JavaAssetManager
, as well as access to the Android Context object. So it is a whole lot more setup, and brings JNI into the picture.