Lock in $30 Savings on PRO—Offer Ends Soon! ⏳

Framework Oriented Programming - Mobilization.pl

Framework Oriented Programming - Mobilization.pl

Pedro Piñera Buendía

October 22, 2016
Tweet

More Decks by Pedro Piñera Buendía

Other Decks in Technology

Transcript

  1. !"#

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

  5. !

  6. !

  7. Architectural Approach Modularizing your apps code bases in local and

    multiplatform frameworks that expose a hookable interface.
  8. mkdir Frameworks; cd Frameworks; pod lib create Core pod lib

    create UI pod lib create Player pod lib create Offline
  9. 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
  10. 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
  11. Transitioning from Monolithic? » Start pulling tooling: » API client.

    » Database wrapper. » Analytics. » Logging » Continue gradually pulling features from the least dependent.
  12. How many frameworks? » It depends on your setup »

    Find the stack that works for you.
  13. One/Multiple repositories? » One repository » Unless: » Other repository

    needs a framework. » You make a framework open source.
  14. Macros #if !os(macOS) import AppKit typealias Image = NSImage #else

    import UIKit typealias Image = UIImage #end
  15. Conclussions » Fewer conflicts in big teams. » Easy multiplatfom

    apps. » Aims good practices (API). Do it if only if your project needs it
  16. 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