Pod for Great Good

B5ff8c85fb809e9966436593b40f1063?s=47 Delisa Mason
February 28, 2014

Pod for Great Good

How to get started building more scalable iOS apps using CocoaPods

B5ff8c85fb809e9966436593b40f1063?s=128

Delisa Mason

February 28, 2014
Tweet

Transcript

  1. 4.

    It used to look like this: • Controllers • Views

    • Model • Helpers • Resources • Tests
  2. 5.

    It used to look like this: • Controllers • Views

    • Model • Helpers • Resources • Tests (I see you there!)
  3. 6.

    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. 7.

    Maybe it’s confusing. So? • Classes may fit into several

    categories • Grouping classes does not enforce the separation of intents per class
  5. 12.
  6. 19.

    How do I get to this magical land?! wow such

    modular much test many iteration
  7. 21.

    Pod Structure • Assets • Classes • Project • README.md

    • WOWSuchLibrary.podspec (Remember to prefix your pod names!)
  8. 22.

    The Podspec • Author info • Description • Dependencies (other

    pods) • Required Frameworks • Supported platforms • Files
  9. 23.

    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" => "iskanamagus@gmail.com" } 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
  10. 24.

    Assets • Images • Sounds • Core Data model •

    Storyboards, XIB files • et cetera
  11. 26.

    README.md “If you don’t have a readme, your code is

    bad and you should feel bad.” — Edsger Dijkstra
  12. 27.

    Project • Contains a default Podfile • Does not generate

    an Xcode project by default • Tests the pod under “real world” conditions
  13. 28.
  14. 29.

    Pod Structure ! • Assets • Classes • Project •

    Example • Example.xcodeproj • ExampleTests • Podfile • README.md • WOWSuchLibrary.podspec
  15. 30.

    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
  16. 31.

    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
  17. 33.

    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
  18. 34.

    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
  19. 35.

    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
  20. 36.

    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”
  21. 37.

    Now your app is here: • Controllers • Views •

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