I have a plugin architecture... the plugins are glorified bundles.
They are compiled at runtime, and embedded in the Main Application Bundle's Plugin folder.
I have hit the point where I need to load the plugins, and query them for data, from inside one of the plugins.
this is usually accomplished in the main bundle with a class :
but Now I am acutely aware that I can't just get the main bundle.
is there a correct way, to get the Host Application's Bundle from a plugin?
They are compiled at runtime, and embedded in the Main Application Bundle's Plugin folder.
I have hit the point where I need to load the plugins, and query them for data, from inside one of the plugins.
this is usually accomplished in the main bundle with a class :
Code Block swift import Foundation import CNPlugin class CNPluginMan{ var plugins : [CNPlugin] = [] init() { loadPlugins() } func loadPlugins(){ do { let files = try FileManager.default.contentsOfDirectory(at: Bundle.main.builtInPlugInsURL!, includingPropertiesForKeys: nil) for URL in files{ let aBundle = Bundle(url: URL) if let als = aBundle?.principalClass{ if let cls = als as? CNPlugin.Type{ let plugin = cls.init() plugins.append(plugin) } } } } catch { print(error) } } }
but Now I am acutely aware that I can't just get the main bundle.
is there a correct way, to get the Host Application's Bundle from a plugin?