<div dir="ltr">Hey guys,<div><br></div><div>I have been able to create simplest possible setup that exhibits this problem, the protobuf module wasn't necessary. All I import is PluginInterface and I get the error:</div><div>
<p class="gmail-p1"><span class="gmail-s1">objc[66212]: Class _TtC15PluginInterface15PluginInterface is implemented in both /Users/Lope/Dev/swift/SwiftPlugins/PluginConsumer/.build/x86_64-apple-macosx10.10/debug/libPluginInterface.dylib (0x10fc7b668) and /Users/Lope/Dev/swift/SwiftPlugins/PluginImplementation/.build/x86_64-apple-macosx10.10/debug/libPluginInterface.dylib (0x1107dd668). One of the two will be used. Which one is undefined.</span></p><p class="gmail-p1"><span class="gmail-s1"><br></span></p><p class="gmail-p1"><span class="gmail-s1">You can find modules on my github:</span></p><p class="gmail-p1"><span class="gmail-s1"><a href="https://github.com/Lopdo/SwiftPlugins-PluginInterface">https://github.com/Lopdo/SwiftPlugins-PluginInterface</a><br></span></p><p class="gmail-p1"><span class="gmail-s1"><a href="https://github.com/Lopdo/SwiftPlugins-PluginImplementation">https://github.com/Lopdo/SwiftPlugins-PluginImplementation</a><br></span></p><p class="gmail-p1"><span class="gmail-s1"><a href="https://github.com/Lopdo/SwiftPlugins-PluginConsumer">https://github.com/Lopdo/SwiftPlugins-PluginConsumer</a><br></span></p><p class="gmail-p1"><br></p><p class="gmail-p1">Could you have a quick look if I didn't mess up or missed something and I will create bug report. If you want to run the code for yourself, you will have to change the path to dylib in the PluginConsumer (I don't know how to use relative path and didn't have time to find out yet)</p></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 8 October 2017 at 09:51, Ján Kosa via swift-users <span dir="ltr"><<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><div dir="ltr">I was afraid it will come to that :) I will try to make something tonight, either it will help you fix it, or I will find out what I did wrong</div></span><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On 8 October 2017 at 09:49, Daniel Dunbar <span dir="ltr"><<a href="mailto:daniel_dunbar@apple.com" target="_blank">daniel_dunbar@apple.com</a>></span> wrote:<br></span><div><div class="h5"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space">Is it possible for you to make a small test package that shows the problem, and file a bug in <a href="http://bugs.swift.org" target="_blank">bugs.swift.org</a>? There may be something we need to fix in SwiftPM before this can work (because of our linking model).<span class="m_2799793014597030083HOEnZb"><font color="#888888"><div><br></div></font></span><div><span class="m_2799793014597030083HOEnZb"><font color="#888888"> - Daniel</font></span><div><div class="m_2799793014597030083h5"><br><div><br><blockquote type="cite"><div>On Oct 7, 2017, at 10:42 PM, Ján Kosa via swift-users <<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>> wrote:</div><br class="m_2799793014597030083m_-6734854148308687225Apple-interchange-newline"><div><div dir="ltr">That is exactly what I did. The only package that depends on the protobuf is the PluginInterface. Both MyPlugin and and PluginConsumer depend on the PluginInterface and not on the protobuf itself. I had to shuffle around my dependencies a bit, which resulted in smaller number of dependencies but they don't make much sense now (as in, some target had to depend on PluginInterface even if they don't need to, just to get access to protobuf). I could live with that if it solved the issue, but it didn't.<div><br></div><div>I am adding my Package.swift files in case I missed something:</div><div><br></div><div>PluginInterface:</div><div><br></div><div>```swift</div><div><span class="m_2799793014597030083m_-6734854148308687225gmail-s1" style="font-family:Menlo;font-size:11px">let</span><span style="font-family:Menlo;font-size:11px"> package = Package(</span></div><p class="m_2799793014597030083m_-6734854148308687225gmail-p2"><span class="m_2799793014597030083m_-6734854148308687225gmail-s2"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>name: </span>"PluginInterface"<span class="m_2799793014597030083m_-6734854148308687225gmail-s2">,</span></p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>products: [ .library(name: <span class="m_2799793014597030083m_-6734854148308687225gmail-s3">"PluginInterface"</span>, type: .dynamic, targets: [<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">"PluginInterface"</span>]) ],</p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>dependencies: [ <span class="m_2799793014597030083m_-6734854148308687225gmail-s2">.package(url: </span>"<a href="https://github.com/apple/swift-protobuf.git" target="_blank">https://github.com/apple/swif<wbr>t-protobuf.git</a>"<span class="m_2799793014597030083m_-6734854148308687225gmail-s2">, from: </span>"0.0.0"<span class="m_2799793014597030083m_-6734854148308687225gmail-s2">) </span>],</p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>targets: [ .target(name: <span class="m_2799793014597030083m_-6734854148308687225gmail-s3">"PluginInterface"</span>, dependencies: [<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">"SwiftProtobuf"</span>]) ]</p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1">)```</p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1"><br></p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1">MyPlugin:</p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1">```swift</p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225gmail-s1">let</span> package = <span class="m_2799793014597030083m_-6734854148308687225gmail-s2">Package</span>(</p><p class="m_2799793014597030083m_-6734854148308687225gmail-p2"><span class="m_2799793014597030083m_-6734854148308687225gmail-s3"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>name: </span>"MyPlugin"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">,</span></p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>products: [ .<span class="m_2799793014597030083m_-6734854148308687225gmail-s4">library</span>(name: <span class="m_2799793014597030083m_-6734854148308687225gmail-s5">"MyPlugin"</span>, type: .<span class="m_2799793014597030083m_-6734854148308687225gmail-s4">dynamic</span>, targets: [<span class="m_2799793014597030083m_-6734854148308687225gmail-s5">"PluginImpl"</span>]) ],</p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>dependencies: [</p><p class="m_2799793014597030083m_-6734854148308687225gmail-p2"><span class="m_2799793014597030083m_-6734854148308687225gmail-s3">.</span><span class="m_2799793014597030083m_-6734854148308687225gmail-s4">package</span><span class="m_2799793014597030083m_-6734854148308687225gmail-s3">(url: </span>"path/to/PluginInterface.git"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">, from: </span>"0.0.0"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">),</span><br></p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>],</p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>targets: [</p><p class="m_2799793014597030083m_-6734854148308687225gmail-p2"><span class="m_2799793014597030083m_-6734854148308687225gmail-s3"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>.</span><span class="m_2799793014597030083m_-6734854148308687225gmail-s4">target</span><span class="m_2799793014597030083m_-6734854148308687225gmail-s3">(name: </span>"PluginImpl"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">, dependencies: [</span>"ProtoBufMessages"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">]),</span></p><p class="m_2799793014597030083m_-6734854148308687225gmail-p2"><span class="m_2799793014597030083m_-6734854148308687225gmail-s3"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>.</span><span class="m_2799793014597030083m_-6734854148308687225gmail-s4">target</span><span class="m_2799793014597030083m_-6734854148308687225gmail-s3">(name: </span>"ProtoBufMessages"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">, dependencies: [</span>"PluginInterface"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">])</span></p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>]</p><div>
<br class="m_2799793014597030083m_-6734854148308687225webkit-block-placeholder"></div><p class="m_2799793014597030083m_-6734854148308687225gmail-p1">)```</p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1"><br></p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1">PluginConsumer:</p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1">```swift</p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225gmail-s1">let</span> package = <span class="m_2799793014597030083m_-6734854148308687225gmail-s2">Package</span>(</p><p class="m_2799793014597030083m_-6734854148308687225gmail-p2"><span class="m_2799793014597030083m_-6734854148308687225gmail-s3"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>name: </span>"PluginConsumer"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">,</span></p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>dependencies: [</p><p class="m_2799793014597030083m_-6734854148308687225gmail-p2"><span class="m_2799793014597030083m_-6734854148308687225gmail-s3"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>.</span><span class="m_2799793014597030083m_-6734854148308687225gmail-s4">package</span><span class="m_2799793014597030083m_-6734854148308687225gmail-s3">(url: </span>"<a href="https://github.com/PerfectlySoft/Perfect-WebSockets.git" target="_blank">https://github.com/PerfectlyS<wbr>oft/Perfect-WebSockets.git</a>"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">, from: </span>"3.0.0"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">),</span></p><p class="m_2799793014597030083m_-6734854148308687225gmail-p2"><span class="m_2799793014597030083m_-6734854148308687225gmail-s3"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>.</span><span class="m_2799793014597030083m_-6734854148308687225gmail-s4">package</span><span class="m_2799793014597030083m_-6734854148308687225gmail-s3">(url: </span>"<a href="https://github.com/PerfectlySoft/Perfect-HTTPServer.git" target="_blank">https://github.com/PerfectlyS<wbr>oft/Perfect-HTTPServer.git</a>"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">, from: </span>"3.0.0"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">),</span></p><p class="m_2799793014597030083m_-6734854148308687225gmail-p2"><span class="m_2799793014597030083m_-6734854148308687225gmail-s3">.</span><span class="m_2799793014597030083m_-6734854148308687225gmail-s4">package</span><span class="m_2799793014597030083m_-6734854148308687225gmail-s3">(url: </span>"path/to/PluginInterface"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">, from: </span>"0.0.0"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">),</span><br></p><p class="m_2799793014597030083m_-6734854148308687225gmail-p2"><span class="m_2799793014597030083m_-6734854148308687225gmail-s3"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>.</span><span class="m_2799793014597030083m_-6734854148308687225gmail-s4">package</span><span class="m_2799793014597030083m_-6734854148308687225gmail-s3">(url: </span>"<a href="https://github.com/krzyzanowskim/CryptoSwift.git" target="_blank">https://github.com/krzyzanows<wbr>kim/CryptoSwift.git</a>"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">, from: </span>"0.0.0"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">)</span></p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>],</p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>targets: [</p><p class="m_2799793014597030083m_-6734854148308687225gmail-p2"><span class="m_2799793014597030083m_-6734854148308687225gmail-s3"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>.</span><span class="m_2799793014597030083m_-6734854148308687225gmail-s4">target</span><span class="m_2799793014597030083m_-6734854148308687225gmail-s3">(name: </span>"AppMaster"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">, dependencies: [</span>"Shared"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">, </span>"CryptoSwift"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">]),</span></p><p class="m_2799793014597030083m_-6734854148308687225gmail-p2"><span class="m_2799793014597030083m_-6734854148308687225gmail-s3"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>.</span><span class="m_2799793014597030083m_-6734854148308687225gmail-s4">target</span><span class="m_2799793014597030083m_-6734854148308687225gmail-s3">(name: </span>"PluginConsumer"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">, dependencies: [</span>"Shared"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">, </span>"CryptoSwift"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">]),</span></p><p class="m_2799793014597030083m_-6734854148308687225gmail-p2"><span class="m_2799793014597030083m_-6734854148308687225gmail-s3"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>.</span><span class="m_2799793014597030083m_-6734854148308687225gmail-s4">target</span><span class="m_2799793014597030083m_-6734854148308687225gmail-s3">(name: </span>"Shared"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">, dependencies: [</span>"ProtoBufMessages"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">, </span>"PerfectHTTPServer"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">, </span>"PerfectWebSockets"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">]),</span></p><p class="m_2799793014597030083m_-6734854148308687225gmail-p2"><span class="m_2799793014597030083m_-6734854148308687225gmail-s3"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>.</span><span class="m_2799793014597030083m_-6734854148308687225gmail-s4">target</span><span class="m_2799793014597030083m_-6734854148308687225gmail-s3">(name: </span>"ProtoBufMessages"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">, dependencies: [</span>"PluginInterface"<span class="m_2799793014597030083m_-6734854148308687225gmail-s3">])</span></p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225gmail-Apple-tab-span">        </span>]</p><div>
<br class="m_2799793014597030083m_-6734854148308687225webkit-block-placeholder"></div><p class="m_2799793014597030083m_-6734854148308687225gmail-p1">)```</p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1"><br></p><p class="m_2799793014597030083m_-6734854148308687225gmail-p1">App master is separate executable that shares some functionality with PluginConsumer, but it doesn't link against it in any way. I guess it could be omitted, but I wanted to give you whole thing as it is</p></div><div class="gmail_extra"><br><div class="gmail_quote">On 7 October 2017 at 18:33, Geordie Jay <span dir="ltr"><<a href="mailto:geojay@gmail.com" target="_blank">geojay@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><br><div class="gmail_quote"><span><div dir="auto">Ján Kosa <<a href="mailto:lopenka@gmail.com" target="_blank">lopenka@gmail.com</a>> schrieb am Sa. 7. Okt. 2017 um 15:27:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>I tried to use <span style="font-size:12.8px">@_exported and it helped somewhat. While I still have same warnings, size of the PluginInterface library went down by 6mb (to 120kb) so it looks like Protobuf is no longer statically linked to it. However, size of PluginConsumer executable went up by same 6mb, it looks like it is linked there twice now. </span></div></blockquote><div dir="auto"><br></div></span><div dir="auto">To be clear: take protobuf out of the PluginConsumer dependencies. Actually, I’m not sure which is which, but protobuf should only be listed as a dependency of one package, where it is imported as @_exported. After that, your other modules depend on the package that imports / exports protobuf.</div><div><div class="m_2799793014597030083m_-6734854148308687225h5"><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><span style="font-size:12.8px"></span><div><span style="font-size:12.8px">I also noticed interesting thing. If I build executable using `swift build` the size is around 17mb, when I generate xcode project and build it using that, size is around 200kb, but I get same warnings using both approaches</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 7 October 2017 at 15:44, Geordie Jay <span><<a href="mailto:geojay@gmail.com" target="_blank">geojay@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><br><div class="gmail_quote"><span><div dir="auto">Ján Kosa <<a href="mailto:lopenka@gmail.com" target="_blank">lopenka@gmail.com</a>> schrieb am Sa. 7. Okt. 2017 um 13:34:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>I tried swift package clean, but it didn't help</div><div><div><br></div><div>"<span style="font-size:12.8px">Try to ensure the plugin provider module (libA) is (only) being compiled into its standalone shared library file." </span></div></div><div><div><span style="font-size:12.8px">How do I go about this? It is 3rd party module, it doesn't define any products (<a href="https://github.com/apple/swift-protobuf.git" target="_blank">https://github.com/apple/swif<wbr>t-protobuf.git</a>). Is there something I can do in my Package files to make sure it is loaded dynamically?</span></div></div></blockquote><div dir="auto"><br></div></span><div dir="auto">When you compile a package depending on protobuf, all the relevant symbols end up in your package’s library file. So here’s something you might try:</div><div dir="auto"><br></div><div dir="auto">import protobuf into your own “PluginProvider” module (package), which has a shared library product like this: ‘@_exported import Protobuf’ in some compiled swift file. Then from the other dependent modules “import PluginProvider” - the protobuf symbols should be available, and all from one (nonconflicting) source.</div><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138HOEnZb"><font color="#888888"><div dir="auto"><br></div><div dir="auto">Geordie</div></font></span><div><div class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138h5"><div dir="auto"><br></div><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><span style="font-size:12.8px"></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 6 October 2017 at 22:52, Geordie Jay <span><<a href="mailto:geojay@gmail.com" target="_blank">geojay@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div dir="auto">I think SwiftPM is (incorrectly) compiling <a href="http://a.xyz/" target="_blank">A.XYZ</a> into each of the modules that depend on it, as well as into your intended libA.so file.</div><div dir="auto"><br></div><div dir="auto">Try to ensure the plugin provider module (libA) is (only) being compiled into its standalone shared library file. Try cleaning the swiftpm build for one (swift package clean) and ensure the Package.swift files are correctly set up to output the shared library.</div><div dir="auto"><br></div><div dir="auto">Sorry I can’t be more specific, I’ve had these same kinds of issues before but I’m not 100% what they were.</div><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554HOEnZb"><font color="#888888"><div dir="auto"><br></div><div dir="auto">Geordie</div></font></span><div><div class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554h5"><div dir="auto"><br></div><br><div class="gmail_quote"><div>Ján Kosa via swift-users <<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>> schrieb am Fr. 6. Okt. 2017 um 14:41:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>It worked! Took me a while to iron out details, but it is working now. Huge thanks sir, I will name my firstborn after you.<div>Thanks for the <span style="font-size:12.8px">@_cdecl("initializePlugin"<wbr>) tip as well, I didn't know about it and it will be very useful.</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">I am having slightly related problem now (it was there before, but I ignored it for the time being), not sure if I should start a new thread?</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">The PluginInterface module has one external dependency on module A, PluginConsumer has the dependency on module B which has dependency on same module A that the PluginInterface uses. When I load the plugin library, I get bunch of errors like:</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Class <a href="http://a.xyz/" target="_blank">A.XYZ</a> is implemented in both libPluginInterface.dylib and libMyPlugin.dylib</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">I know why it is there, but I don't know how to get rid of it. I can't just remove dependency from PluginConsumer and use the one from PluginInterface (if that would even work?) because PluginConsumer does not depend on it directly, but it is going through module B first</span></div><div><span style="font-size:12.8px"><br></span></div><div><span style="font-size:12.8px">Cheers,</span></div><div><span style="font-size:12.8px">Lope</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 4 October 2017 at 22:17, Daniel Dunbar <span><<a href="mailto:daniel_dunbar@apple.com" target="_blank">daniel_dunbar@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word;line-break:after-white-space">The way that I have done this in the past is pass a protocol as an unsafe pointer to an exposed entry point:<div>```swift</div><div> let entryPoint = dlsym(handle, “initializePlugin”)</div><div> guard entryPoint != nil else {</div><div> fatalError("missing plugin entry point: \(pluginPath)")</div><div> }</div><div> typealias PluginInitializationFunc = @convention(c) (UnsafeRawPointer) -> ()</div><div> let f = unsafeBitCast(entryPoint, to: PluginInitializationFunc.self)</div><div> f(Unmanaged.passUnretained(sel<wbr>f).toOpaque())</div><div>```</div><div><br></div><div>and then in the plugin convert back to the appropriate type:</div><div><br></div><div>```</div><div><div>@_cdecl("initializePlugin")</div><div>public func initializePlugin(_ ptr: UnsafeRawPointer) {</div><div> let manager = Unmanaged<PluginManager>.fromO<wbr>paque(ptr).takeUnretainedValue<wbr>()</div><div>```</div><div><br></div><div>HTH,</div><div> - Daniel</div><div><br><blockquote type="cite"><div><div class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901h5"><div>On Oct 4, 2017, at 11:02 AM, Ján Kosa via swift-users <<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a>> wrote:</div><br class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761Apple-interchange-newline"></div></div><div><div><div class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901h5"><div>Hello folks,<div><br></div><div>I have been toying with dynamic libraries, trying to implement plugin functionality. I was able to get to the point where I can call simple function in loaded library, but I am having troubles starting more sophisticated communication channel.</div><div><br></div><div>There are 3 projects<br></div><div>- PluginConsumer is an app that loads plugin libraries </div><div>- MyPlugin is a plugin implementation, output is dynamic library that PluginConsumer loads</div><div>- PluginInterface is common interface that both MyPlugin and PluginConsumer use, so that they know how to communicate</div><div><br></div><div>My first idea was to have PluginInterface be a simple SPM project with single file where the bare-bones PluginInterface class would be:</div><div><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1"><br></span></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1">open</span> <span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1">class</span> PluginInterface {</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p2"> open func sayHi()</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1">}</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1"><br></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1">Package.swift file:</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1"><br></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p2">// swift-tools-version:4.0</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1">import</span> PackageDescription</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1">let</span> package = Package(</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p4"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s2"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span> name: </span>"PluginInterface"<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s2">,</span></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span> products: [ .library(name: <span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s3">"PluginInterface"</span>, type: .dynamic, targets: [<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s3">"PluginInterface"</span>]) ],</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span> targets: [ <span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s2">.target(name: </span>"PluginInterface"<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s2">) </span>]</p><div>
<br class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761webkit-block-placeholder"></div><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3">)</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><br></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><br></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1">UserPlugin is also very simple project containing only one file:</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1"><br></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1">public</span> <span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1">func</span> getPlugin() -> <span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s2">AnyObject</span> {</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p2"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s3"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span></span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1"> return</span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s3"> </span>MyPlugin<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s3">()</span></p><div>
<br class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761webkit-block-placeholder"></div><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1">}</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1"><br></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1">class MyPlugin: PluginInterface {</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1"> override func sayHi() {</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1"> print("Hi from my plugin")</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1"> }</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1">}</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1">Package.swift:</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1"><br></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p2">// swift-tools-version:4.0</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1">import</span> PackageDescription</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1">let</span> package = <span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s2">Package</span>(</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p4"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s3"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span> name: </span>"MyPlugin"<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s3">,</span></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span> products: [ .<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s4">library</span>(name: <span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s5">"MyPlugin"</span>, type: .<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s4">dynamic</span>, targets: [<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s5">"MyPlugin"</span>]) ],</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span> dependencies: [ .<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s4">package</span>(url: <span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s5">"url_to_PluginInterface"</span>, from: <span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s5">"0.0.0"</span>), ],</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span> targets: [</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p4"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s3"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span> .</span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s4">target</span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s3">(name: </span>"PluginInterface"<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s3">, dependencies: [</span>"PluginInterface"<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s3">]),</span></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span> .<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s4">target</span>(name: <span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s5">"MyPlugin"</span>, dependencies: [<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s5">"PluginInterface"</span>]),</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span> ]</p><div>
<br class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761webkit-block-placeholder"></div><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3">)</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1"><br></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1">The PluginConsumer is bit more complicated, but here is relevant part (lib loading and function calling):</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1"><br></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1">typealias</span> <span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s2">I</span>nitFunction = <span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1">@convention</span>(c) () -> <span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s3">AnyObject</span></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p2"><br></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1">let</span> openRes = <span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s4">dlopen</span>(<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s2">p</span>athToLib, <span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s3">RTLD_NOW</span>|<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s3">RTLD_LOCAL</span>)</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s5">i</span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1">f</span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s6"> </span>openRes<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s6"> != </span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1">nil</span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s6"> {</span></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p4"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s6"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span></span> defer<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s6"> {</span></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p5"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s6"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span></span> dlclose<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s6">(</span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s7">openRes</span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s6">)</span></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span> }</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p6"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1"> let</span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s6"> symbolName = </span>"mangled_symbol_name"<br></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1"> let</span> sym = <span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s4">dlsym</span>(<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s7">openRes</span>, symbolName)</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p2"><br></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1"> if</span> sym != <span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1">nil</span> {</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s6"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span></span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1"> let</span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s6"> f: </span>InitFunction<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s6"> = </span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s4">unsafeBitCast</span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s6">(sym, to: </span>InitFunction<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s6">.</span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1">self</span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s6">)</span></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1"> let</span> plugin = f() as? PluginInterface</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span> }</p><div>
<br class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761webkit-block-placeholder"></div><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1">}</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1">Package.swift file:</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p1">// swift-tools-version:4.0</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1">import</span> PackageDescription</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1">let</span> package = <span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s2">Package</span>(</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span> name: <span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s3">"PluginConsumer"</span>,</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span> dependencies: [ <span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s4">.</span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s5">package</span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s4">(url: </span>"path_to_plugin_interface"<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s4">, from: </span>"0.0.0"<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s4">) </span>],</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-Apple-tab-span"></span> targets: [ <span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s4">.</span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s5">target</span><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s4">(name: </span>"PluginConsumer"<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s4">, dependencies: [</span>"PluginConsumer"<span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s4">]) </span>]</p><div>
<br class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761webkit-block-placeholder"></div><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3">)</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><br></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3">This all compiles nicely, MyPlugin project creates dylib file that executable created by PluginConsumer can load, but the problem is with following line:</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><span class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-s1">let</span> plugin = f() as? PluginInterface<br></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3">Type of the plugin is MyPlugin, but from the consumer's view, it doesn't inherit from PluginInterface so I can't call sayHi() method. I assume this is because there is no relation between PluginInterface class that compiler uses for MyPlugin project one that it uses for PluginConsumer project. After library is loaded, they are two completely different classes that happen to share same name. Is my assumption correct and how do I go about fixing it?</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3">I had an idea I could make PluginInterface emit dynamic library that would be dynamically linked by both MyPlugin and PluginConsumer, thus making them share same PluginInterface class, but I can't figure out how to do that (or if it's right way of doing this).<br></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3"><br></p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3">Any help appreciated :)</p><p class="m_2799793014597030083m_-6734854148308687225m_-4294955562354230567m_8729161781951157138m_8602944998557321586m_3476204009829642554m_2109301194184823821m_5965118442678244901m_1431573529807325761gmail-p3">Lope</p></div></div></div></div>
______________________________<wbr>_________________<br>swift-users mailing list<br><a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-users" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-users</a><br></div></blockquote></div><br></div></div></blockquote></div><br></div>
______________________________<wbr>_________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-users</a><br>
</blockquote></div></div></div></div>
</blockquote></div><br></div>
</blockquote></div></div></div></div>
</blockquote></div><br></div>
</blockquote></div></div></div></div>
</blockquote></div><br></div>
______________________________<wbr>_________________<br>swift-users mailing list<br><a href="mailto:swift-users@swift.org" target="_blank">swift-users@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-users" target="_blank">https://lists.swift.org/mailma<wbr>n/listinfo/swift-users</a><br></div></blockquote></div><br></div></div></div></div></blockquote></div></div></div><br></div>
<br>______________________________<wbr>_________________<br>
swift-users mailing list<br>
<a href="mailto:swift-users@swift.org">swift-users@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-users" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-users</a><br>
<br></blockquote></div><br></div>