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

CocoaPods 2015 talk

CocoaPods 2015 talk

Talk about the current state of CocoaPods, best practices and some of its internals. Given at iOSDevCampDC 2015.

Boris Bügling

September 04, 2015
Tweet

More Decks by Boris Bügling

Other Decks in Programming

Transcript

  1. Agenda • What's new and upcoming • CocoaPods plugins •

    How does CocoaPods even • Troubleshooting and Tips
  2. Target Deduplication Happens by default, exceptions: • They are used

    on different platforms. • They are used with differents sets of subspecs. • They have any dependency which needs to be duplicated.
  3. Breaking Change to the Hooks- API post_install do |installer_or_rep| #

    @note: Remove after CocoaPods 0.38+ is completely rolled out # and rename block argument to `installer`. installer = installer_or_rep.respond_to?(:installer) ? installer_or_rep.installer : installer_or_rep # You can use the installer from now on. end
  4. Other changes • Removal of the Enviroment Header • Deterministic

    UUIDs by Xcodeproj • Resolver takes the Deployment Target into account
  5. CocoaPods 0.39 • currently beta 4 • Vendored dynamic frameworks

    ! • --private option for linting (ignore warnings only suitable for trunk) • HEADER_SEARCH_PATHS is no longer constructed recursively
  6. CocoaPods plugins • Add subcommands to pod, the tool •

    post_install hook • Each plugin is a Gem
  7. $ tree . ├── Gemfile ├── LICENSE.txt ├── README.md ├──

    Rakefile ├── cocoapods_awesome_plugin.gemspec └── lib ├── cocoapods_awesome_plugin.rb ├── cocoapods_plugin.rb └── pod └── command └── plugin.rb 3 directories, 8 files
  8. module Pod class Command class Plugin < Command self.summary =

    "Short description." self.arguments = [CLAide::Argument.new('NAME', true)] def initialize(argv) @name = argv.shift_argument super end def validate! super help! "A Pod name is required." unless @name end def run UI.puts "Add your implementation here" end
  9. Check Pods Manifest.lock diff "${PODS_ROOT}/../Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null if [[

    $? != 0 ]] ; then cat << EOM error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation. EOM exit 1 fi
  10. Radar 22392501 Actual Results: It doesn't. You receive this error

    when archiving: [...] So, because they have the same product name, they're overriding each other. How are we supposed to use our own frameworks from our different target types?
  11. Mixing Objective-C and Swift in a Pod • Frameworks can't

    have a separate bridging header • Objective-C headers can be included in the umbrella header
  12. Second solution: publiclize all the things • Create a header

    • Import all the Objective-C headers you need • Add that header to public_header_files => Exposes the dependency in the public API
  13. Third solution: custom module map • Module maps can have

    private submodules framework module ResearchKit { umbrella header "ResearchKit.h" module Private { umbrella header "ResearchKit_Private.h" export * } export * module * { export * } } • Can be declared in the podspec with module_map
  14. Filing issues • Read our contribution guidelines • Try if

    your problem reproduces in a separate project • Give us that project! => Help us help you
  15. Use bundler to pin your used CocoaPods version $ cat

    Gemfile source 'https://rubygems.org' gem 'cocoapods', '= 0.36.0.beta.1' $ bundle install $ bundle exec pod install # from now on
  16. Make sure your dependencies don't go away • Commit the

    Pods directory • Mirror your Pods (https://github.com/xing/ XNGPodsSynchronizer)
  17. You can keep the Pods history separate • Create an

    orphaned branch on your repo • Check it out as a submodule to Pods • History is now completely separate
  18. Automate your workflow • Use plugins • Use a Rakefile

    or Makefile for common tasks • Use pre_install or post_install hooks in the Podfile