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

Framework Oriented Programming - MobiConf 2016

Framework Oriented Programming - MobiConf 2016

Have you ever tried to reuse code from your mobile apps and you haven’t been able to? Did you start using frameworks only when Apple suggested it for Watch Extensions?

With more platforms coming out, there's a clear need of bundling logic that can be reused and shared in multiple platforms. Frameworks will help us with that and will benefit our application code bases in many ways.

Learn how to do it, with or without dependency manager involved, recommendations and some caveats you must keep in mind. Start building your own Foundation frameworks, reusable, well designed, and with single responsibilities.

B0a336761194918a853deeff1f22b537?s=128

Pedro Piñera Buendía

October 06, 2016
Tweet

Transcript

  1. FRAMEWORK ORIENTED PROGRAMMING @PEPIBUMUR / PEPIBUMUR@GMAIL.COM

  2. None
  3. CZEŚĆ! ! Pedro IOS DEVELOPER AT SOUNDCLOUD @PEPIBUMUR TWITTER/GITHUB WWW.PPINERA.ES

  4. FRAMEWORK ORIENTED PROGRAMMING

  5. CONTEXT HOW TIPS DOWNSIDES

  6. None
  7. BOX

  8. THINGS WITH SOMETHING IN COMMON

  9. !"#

  10. None
  11. None
  12. BOXES FRAMEWORKS

  13. In computer science, a framework is a collection of implementations

    of behavior, written in terms of a language, that has a well-defined interface by which the behavior is invoked Wikipedia
  14. EXTERNAL FRAMEWORKS

  15. None
  16. inhibit_all_warnings! use_frameworks! target 'MyApp' do pod "PureLayout" pod 'FLEX' pod

    'DateTools' pod 'Reachability' pod 'RxSwift' pod 'SDWebImage' pod "SDVersion" pod 'BlocksKit' pod 'CTFeedback' pod 'TOWebViewController' pod '1PasswordExtension' pod 'SlackTextViewController' pod 'FeedbackMe' pod 'Localize-Swift' pod 'Smooch' pod 'Fabric' pod 'Crashlytics' pod 'CWStatusBarNotification' pod "ImagePickerSheetController" pod 'KYNavigationProgress' end
  17. ! 1 APP TARGET + X EXTERNAL FRAMEWORKS

  18. SIMPLE PROJECTS

  19. SMALL TEAMS (and not distributed)

  20. ONLY 1-2 PLATFORMS ! "

  21. !

  22. NEW PLATFORMS !"⌚$

  23. None
  24. None
  25. None
  26. None
  27. None
  28. None
  29. None
  30. None
  31. None
  32. None
  33. SIMPLE COMPLEX PROJECTS

  34. COULDN'T REUSE CODE SCALE EASILY

  35. BIGGER PROJECTS BIGGER TEAMS (and also distributed)

  36. CONFLICTS BETWEEN TEAMS (Interdependencies)

  37. None
  38. None
  39. None
  40. None
  41. None
  42. None
  43. None
  44. !

  45. !

  46. FRAMEWORK ORIENTED PROGRAMMING

  47. Architectural Approach MODULARIZING YOUR APPS CODE BASES IN LOCAL AND

    MULTIPLATFORM FRAMEWORKS THAT EXPOSE A HOOKABLE INTERFACE.
  48. NEW PLATFORMS/TARGETS GLUING

  49. None
  50. ATOMIC TEAMS THAT OWN FRAMEWORKS

  51. None
  52. DECIDE ABOUT PERSISTENCE DECIDE ABOUT PATTERNS DECIDE ABOUT ARCHITECTURE DECIDE

    ABOUT LANGUAGE
  53. FRAMEWORK EXPOSES AN API

  54. None
  55. FEWER INTERDEPENDENCIES FEWER CONFLICTS FEWER BUGS

  56. None
  57. None
  58. HOW TO SETUP THE PROJECT

  59. USING COCOAPODS CREATE PODS LINK THE PROJECT AGAINST THEM

  60. mkdir Frameworks; cd Frameworks; pod lib create Core pod lib

    create UI pod lib create Player pod lib create Offline
  61. Pod::Spec.new do |s| s.name = 'Player' s.dependency 'Core' s.dependency 'UI'

    end
  62. abstract_target 'Frameworks' do pod "Core", :path => "Frameworks/Core" pod "UI",

    :path => "Frameworks/UI" pod "Player", :path => "Frameworks/Player" pod "Offline", :path => "Frameworks/Offline" # Platforms target "MyApp" target "MyTVApp" target "MyWatchApp" end
  63. MANUALLY CREATING/LINKING

  64. WORKSPACE MULTIPLE FRAMEWORK PROJECTS LINKED/EMBEDDED

  65. None
  66. None
  67. None
  68. MULTI-PLATFORM FRAMEWORK # Supported platforms SUPPORTED_PLATFORMS = iphoneos iphonesimulator appletvsimulator

    appletvos macosx watchsimulator watchos # Valid architectures VALID_ARCHS[sdk=macosx*] = x86_64 VALID_ARCHS[sdk=iphone*] = arm64 armv7 armv7s # Frameworks Search Path LD_RUNPATH_SEARCH_PATHS[sdk=iphone*] = $(inherited) @executable_path/Frameworks @loader_path/Frameworks LD_RUNPATH_SEARCH_PATHS[sdk=macosx*] = $(inherited) @executable_path/../Frameworks @loader_path/../Frameworks LD_RUNPATH_SEARCH_PATHS[sdk=watch*] = $(inherited) @executable_path/Frameworks @loader_path/Frameworks LD_RUNPATH_SEARCH_PATHS[sdk=appletv*] = $(inherited) @executable_path/Frameworks @loader_path/Frameworks
  69. None
  70. TIPS

  71. MINIMIZE EXTERNAL DEPENDENCIES (Do it by yourself)

  72. HOW FRAMEWORKS ARE LINKED? SHOULD A FRAMEWORK BE EMBEDDED? CAN

    I LINK IT STATICALLY?
  73. ANALYZE EXISTING TOOLS (e.g. CocoaPods)

  74. None
  75. None
  76. FIND THE SETUP THAT WORKS FOR YOU

  77. FREELANCE

  78. FEATURE TEAMS

  79. MULTI-PLATFORM APPS

  80. DEFINE A PUBLIC CONTRACT AND COMMUNICATION PATTERNS

  81. INTERNAL BY DEFAULT

  82. MONOREPO UNIFIED VERSIONING

  83. DOWNSIDES

  84. DOCUMENTATION NOT GOOD ENOUGH

  85. NO HOMOGENEITY APIS

  86. MACROS #if !os(macOS) import AppKit typealias Image = NSImage #else

    import UIKit typealias Image = UIImage #end
  87. XCODE HAS A LONG WAY TO GO ! "

  88. CONCLUSSIONS ▸ Fewer conflicts in big teams. ▸ Easy multiplatfom

    apps. ▸ Aims good practices (API). DO IT IF ONLY IF YOUR PROJECT NEEDS IT
  89. REFERENCES ▸ frameworkoriented.io ▸ Building Modern Frameworks ▸ How to

    create a Framework for iOS ▸ Framework vs Library ▸ Static and Dynamic libraries ▸ The Unofficial Guide to xcconfig files
  90. THANKS QUESTIONS? @PEPIBUMUR / PEPIBUMUR@GMAIL.COM PHOTOS FROM UNSPLASH SLIDES BIT.LY/FRAMEWORKORIENTED

  91. None