Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Plug-in architecture pattern with Swift

Plug-in architecture pattern with Swift

Talk at 11° CocoaHeads Fortaleza

F380535da59d6cdd5754e2e31bda8a0e?s=128

Bruno Macabeus

May 26, 2017
Tweet

Transcript

  1. PLUG-IN ARCHITECTURE PATTERN WITH SWIFT 11° COCOAHEADS FORTALEZA

  2. WHO AM I?

  3. Bruno Macabeus macabeus

  4. WHY SHOULD I USE PLUGIN ARCHITECTURE?

  5. None
  6. None
  7. It's open! (๑>◡<๑) https://github.com/stalkr-io http://getstal.kr

  8. HOW PLUGIN ARCHITECT WORK?

  9. Also called as “microkernel architecture” Source: www.oreilly.com/ideas/software-architecture-patterns/page/4/microkernel-architecture

  10. BRIEF EXAMPLE WITH PYTHON

  11. None
  12. None
  13. None
  14. None
  15. None
  16. None
  17. pyCertificate/ main.py plugin/ Certificado.py - loads the plugins - base

    class Certificado, with abstract attributes
  18. assinaturas/ plugin/ alynne.py edson.py certificado/ CertificadoEventoPalestrante.py CertificadoEventoOuvinte.py logo/ ifce.py

  19. Going go to PyCharm

  20. NOW… HOW TO MAKE IT WITH SWIFT?

  21. HEY… ONE LITTLE ADVICE

  22. WARNING Everything here is experiments!!

  23. USEFUL but, it is…

  24. MY ATTEMPTS - DYLIB - BUNDLES

  25. ST 1 ATTEMPT DYNAMIC LIBRARIES

  26. Dynamic libraries: a.k.a dynamic shared libraries, shared objects, or dynamically

    linked libraries O que por nesse slide???
  27. App using static libraries Source: https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/OverviewOfDynamicLibraries.html

  28. App using dynamic libraries Source: https://developer.apple.com/library/content/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/OverviewOfDynamicLibraries.html

  29. Create a new dylib in Swift

  30. Use your dylib with Swift

  31. Eeeeh! It’s work!!

  32. NO It’s not work in iOS/ tvOS

  33. I sent a e-mail for Apple Engineer support: I want

    to compile a dynamic library to use in my apple tv's application. My dylib is wrote with Swift. I tried (see "Steps to Reproduce" section), but I can't load my dylib neither at simulator nor at physical device. Then I received: Thank you for contacting Apple Developer Technical Support (DTS). Our engineers have reviewed your request and have concluded that there is no supported way to achieve the desired functionality given the currently shipping system configurations.
  34. 2 ATTEMPT BUNDLES ND

  35. Ohh! I found a Apple’s documentation with a suggestive name

    and, this documentation explain about “Bundle”… but… what is it?
  36. Bundles provide a interface to encapsulate executable (dylib, for example)

    and the resources (xib, for example). Source: https://developer.apple.com/library/content/documentation/CoreFoundation/Conceptual/CFBundles/AboutBundles/AboutBundles.html
  37. Somebody make this things to iOS? Or with Swift? Yes!

    Somebody make it work in iOS! So so… Somebody make it work with Swift + Objc-C
  38. Then… I created a Proof of Concept purely in Swift

    with a app to iOS, to send a AppStore
  39. Eeeeh! It’s work!!

  40. NO I can’t send it to AppStore

  41. For some reasons, I can’t send it to AppStore -

    problem in certificate in bundle - size of app - and others random problems
  42. BUT… THE MAJOR PROBLEM IS…

  43. None
  44. None
  45. OTHER EXPERIMENTS - SCRIPT - LLVM C API

  46. 1 EXPERIMENT SCRIPT ST

  47. Maybe another strategy is using not compiled code, but yes

    a script to download and execute in run time!
  48. With JS, we have a proof of concept to run

    JS in AppleTV
  49. 2 EXPERIMENT LLVM C API ND

  50. What is LLVM? Well… LLVM is “Low Level Virtual Machine”,

    and it’s not only one virtual machine Source: http://aosabook.org/en/llvm.html
  51. Example of C code to LLVM IR C LLVM IR

    Source: http://aosabook.org/en/llvm.html
  52. Then, Alex Desinov created a example of using LLVM C

    API with Swift
  53. WORKAROUND…

  54. Well… We can use a simple workaround… We could make

    the app 100% open source and, if the user wants create a plugin, he will need create a new file in the project. Some tools, like Fastlane, can help
  55. Create a reflexive code can help… READ IT IN MY

    BLOG!! macalogs.com.br
  56. SOME OTHERS THINGS…

  57. Like Apple kill the dlopen in NSUserDefault, him can kill

    others solutions that appear. Apple has been closing any way to create a app can execute arbitrary code, even with respondsToSelector and performSelector
  58. ABI

  59. LITERATURE

  60. http://aosabook.org/en/

  61. https://www.oreilly.com/ideas/software-architecture-patterns