Skip to content

Commit e413036

Browse files
authored
always load extensions (#615)
1 parent d4b6420 commit e413036

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Loop/Plugins/PluginManager.swift

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ class PluginManager {
2727
log.debug("Found loop plugin: %{public}@", pluginURL.absoluteString)
2828
bundles.append(bundle)
2929
}
30+
31+
// extensions are always instantiated
32+
if bundle.isLoopExtension {
33+
log.debug("Found loop extension: %{public}@", pluginURL.absoluteString)
34+
_ = try? bundle.loadAndInstantiateExtension()
35+
}
3036
}
3137
}
3238
} catch let error {
@@ -36,8 +42,6 @@ class PluginManager {
3642
self.pluginBundles = bundles
3743
}
3844

39-
40-
4145
func getPumpManagerTypeByIdentifier(_ identifier: String) -> PumpManagerUI.Type? {
4246
for bundle in pluginBundles {
4347
if let name = bundle.object(forInfoDictionaryKey: LoopPluginBundleKey.pumpManagerIdentifier.rawValue) as? String, name == identifier {
@@ -248,4 +252,14 @@ extension Bundle {
248252
var isLoopExtension: Bool { object(forInfoDictionaryKey: LoopPluginBundleKey.extensionIdentifier.rawValue) as? String != nil }
249253

250254
var isSimulator: Bool { object(forInfoDictionaryKey: LoopPluginBundleKey.pluginIsSimulator.rawValue) as? Bool == true }
255+
256+
fileprivate func loadAndInstantiateExtension() throws -> NSObject? {
257+
try loadAndReturnError()
258+
259+
guard let principalClass = principalClass as? NSObject.Type else {
260+
return nil
261+
}
262+
263+
return principalClass.init()
264+
}
251265
}

0 commit comments

Comments
 (0)