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.

Pedro Piñera Buendía

October 06, 2016
Tweet

More Decks by Pedro Piñera Buendía

Other Decks in Technology

Transcript

  1. BOX

  2. !"#

  3. 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
  4. 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
  5. !

  6. !

  7. !

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

    MULTIPLATFORM FRAMEWORKS THAT EXPOSE A HOOKABLE INTERFACE.
  9. mkdir Frameworks; cd Frameworks; pod lib create Core pod lib

    create UI pod lib create Player pod lib create Offline
  10. 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
  11. 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
  12. MACROS #if !os(macOS) import AppKit typealias Image = NSImage #else

    import UIKit typealias Image = UIImage #end
  13. CONCLUSSIONS ▸ Fewer conflicts in big teams. ▸ Easy multiplatfom

    apps. ▸ Aims good practices (API). DO IT IF ONLY IF YOUR PROJECT NEEDS IT
  14. 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