From a1fcaadd85f10ca3addcf3ab20669e809d80c8d8 Mon Sep 17 00:00:00 2001 From: jahorton Date: Fri, 23 Jul 2021 09:02:34 +0700 Subject: [PATCH] fix(ios/engine): engine migration must precede installs --- .../Resource Management/ResourceFileManager.swift | 12 ++++++++++++ ios/samples/KMSample2/KMSample2/AppDelegate.swift | 2 ++ 2 files changed, 14 insertions(+) diff --git a/ios/engine/KMEI/KeymanEngine/Classes/Resource Management/ResourceFileManager.swift b/ios/engine/KMEI/KeymanEngine/Classes/Resource Management/ResourceFileManager.swift index 30056d523d..ac8c9f9d39 100644 --- a/ios/engine/KMEI/KeymanEngine/Classes/Resource Management/ResourceFileManager.swift +++ b/ios/engine/KMEI/KeymanEngine/Classes/Resource Management/ResourceFileManager.swift @@ -328,6 +328,18 @@ public class ResourceFileManager { throw KMPError.resourceNotInPackage } + /** + * A surprisingly critical line. The Manager.shared instance must be initialized at some + * point before the resources are _actually_ stored and reigstered. Otherwise, the initial + * Migrations pass (called early in Manager.init) will interpret the installation as from a + * different engine version and will break anything installed before it's run. + * + * Fortunately... all 14.0's installation methods pass through this single method in order to + * do the actual "storing" and "registering". So, it's a decent-enough place to force + * Manager.shared's init. + */ + _ = Manager.shared + do { try copyWithOverwrite(from: package.sourceFolder, to: Storage.active.packageDir(for: package)!) diff --git a/ios/samples/KMSample2/KMSample2/AppDelegate.swift b/ios/samples/KMSample2/KMSample2/AppDelegate.swift index f27725c98c..bff8a7e0a4 100644 --- a/ios/samples/KMSample2/KMSample2/AppDelegate.swift +++ b/ios/samples/KMSample2/KMSample2/AppDelegate.swift @@ -20,6 +20,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { KeymanEngine.log.logAppDetails() // Replace with your application group id + // Ensure this happens before installing any keyboards or models within the engine + // whenever using App Group Identifiers. Manager.applicationGroupIdentifier = "group.KMSample" return true }