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

Pod for Great Good

Delisa Mason
February 28, 2014

Pod for Great Good

How to get started building more scalable iOS apps using CocoaPods

Delisa Mason

February 28, 2014
Tweet

More Decks by Delisa Mason

Other Decks in Programming

Transcript

  1. It used to look like this: • Controllers • Views

    • Model • Helpers • Resources • Tests
  2. It used to look like this: • Controllers • Views

    • Model • Helpers • Resources • Tests (I see you there!)
  3. Now your app is here: • Controllers • Views •

    Model • Networking • Synchronization • Authentication • My Grandma • Old Stuff • Really Old Stuff • Analytics • Resources • Tests (Do we still need this? Oh right for that one thing…) (Oh, that’s where grandma went!)
  4. Maybe it’s confusing. So? • Classes may fit into several

    categories • Grouping classes does not enforce the separation of intents per class
  5. How do I get to this magical land?! wow such

    modular much test many iteration
  6. Pod Structure • Assets • Classes • Project • README.md

    • WOWSuchLibrary.podspec (Remember to prefix your pod names!)
  7. The Podspec • Author info • Description • Dependencies (other

    pods) • Required Frameworks • Supported platforms • Files
  8. Example Podspec @version = "1.0.0" ! Pod::Spec.new do |s| s.name

    = "TAPI" s.version = @version s.summary = "Cotap API client" s.homepage = "https://github.com/cotap/TAPI" ! s.author = { "Delisa Mason" => "[email protected]" } s.source = { :git => "https://github.com/cotap/TAPI.git", :tag => @version } s.source_files = 'Classes/Public/*.h' s.requires_arc = true s.public_header_files = ['Classes/Public/*.h'] ! # minimum deployment targets s.ios.deployment_target = '6.0' s.osx.deployment_target = '10.8' ! # pod dependencies s.dependency 'AFNetworking', '2.1.0' s.dependency 'ObjectiveSugar', '1.1.0' ! s.subspec 'Client' do |ss| ss.source_files = 'Classes/Client/*.{h,m}' end end
  9. Assets • Images • Sounds • Core Data model •

    Storyboards, XIB files • et cetera
  10. README.md “If you don’t have a readme, your code is

    bad and you should feel bad.” — Edsger Dijkstra
  11. Project • Contains a default Podfile • Does not generate

    an Xcode project by default • Tests the pod under “real world” conditions
  12. Pod Structure ! • Assets • Classes • Project •

    Example • Example.xcodeproj • ExampleTests • Podfile • README.md • WOWSuchLibrary.podspec
  13. Pod Example Podfile platform :osx pod 'WOWSuchLibrary', :path => ‘../'

    # Reference to the new pod pod "ObjectiveSugar" # Ruby-like collection operators/helpers ! target "ExampleTests", :exclusive => true do pod "Kiwi/XCTest" end
  14. Pod Example Podfile pod 'WOWSuchLibrary', :path => ‘../' # Reference

    to the new pod pod "ObjectiveSugar" # Ruby-like collection operators/helpers ! target "ExampleOSXTests", :exclusive => true do platform :osx pod "Kiwi/XCTest" end target "ExampleiOSTests", :exclusive => true do platform :ios pod "Kiwi/XCTest" end For platform-specific files
  15. Good Habits “Write the specifications of the library first before

    bringing in source code, to ensure the library can stand alone and has a distinct purpose.” ! — Abraham Lincoln
  16. Finding Components in Existing Code • Choose a purpose for

    the library • (Hopefully) have an existing group of related files • Seed Classes and ExampleTests with the extraction • Have enough coverage to determine effectiveness
  17. Common Places to Find Components • Data model and model

    classes • Reusable views • "Logic for X" • Classes for interacting with a particular web service • Reusable assets
  18. Good Habits “While a component perhaps cannot be extracted from

    all large chunks of inter- dependent code, existing classes can be made more modular by extracting the methods implemented for a particular protocol into a separate class.” ! — Tom Cruise, “Top Gun”
  19. Now your app is here: • Controllers • Views •

    Model • Tests • Pods • Networking • Model • Analytics • Authentication }• Separate git repos • Tests in isolation • Versioned