Skip to content

cocoaheads-kyiv-14-workshop/magic-ball

Repository files navigation

🔮 magic-ball

Main project

Environment

  • Xcode 10.0
  • CocoaPods 1.5.3
  • Fastlane 2.100
  • Slather 2.4.6

History

  • Created Xcode project MagicBall
  • Setup Gemfile
  • Created local pod RandomGenerator: bundle exec pod lib create RandomGenerator
  • Created Podfile: bundle exec pod init
  • Integrated RandomGenerator into MagicBall (see Podfile)
  • Created local pod Tutorial: bundle exec pod lib create Tutorial
  • Integrated RandomGenerator into Tutorial as a local pod (see Tutorial.podspec and Tutorial/Example/Podfile)
  • Integrated Tutorial into MagicBall (see Podfile)
  • Fixed Xcode 10 issue with not compiling new changes from local pods
  • As a result, we are able to develop separate interdependent modules in a single repo using CocoaPods

We now need to extract local pods into private repos:

  • Registered private Specs repo: bundle exec pod repo add magic-ball-specs git@github.com:cocoaheads-kyiv-14-workshop/specs.git
  • Moved RandomGenerator from MagicBall local pods into separate private repo pod
  • Published RandomGenerator 0.1.0 version: bundle exec pod repo push magic-ball-specs RandomGenerator.podspec --allow-warnings --verbose
  • Switched Tutorial to private RandomGenerator repo instead of local one (see Tutorial/Example/Podfile)
  • Switched MagicBall to private RandomGenerator repo instead of local one (see Podfile)
  • As a result, we are able to develop mixed interdependent modules - local and from private repos at the same time using CocoaPods
  • Moved Tutorial from MagicBall local pods into separate private repo pod
  • Published Tutorial 0.1.0 version: bundle exec pod repo push magic-ball-specs Tutorial.podspec --allow-warnings --verbose --sources='git@github.com:cocoaheads-kyiv-14-workshop/specs.git',master
  • Switched MagicBall to private Tutorial repo instead of local one (see Podfile)
  • As a result, we are able to develop private interdependent modules at the same time using CocoaPods

Automating things

This pod repo push ... command and the whole flow of updating version and creating a new tag might become really annoying.
So we decide to automate the whole release process. Fastlane will help us with this.

  • Created lane to automate routine release tasks:
    bundle exec fastlane release on any branch - that's how simple it is
    bundle exec fastlane release version:1.2.3 message:"my new version" - advanced usage
    • register specs repo if one isn't yet in your system
    • check if current branch is clean
    • checkout to master and pull any changes
    • update version in podspec, either to one from version argument, or patch update by default
    • commit and push to master with message, either from message argument, or default one
    • create tag either from version argument, or from default patch version update and push it
    • finally, validate and push pod to specs repo

We now need to share this lane across multiple private pod repos.
Git submodules? Another pod? :) Fastlane import!

  • Created shared-lanes repo to store lanes that should be shared between private pods
  • Imporing release lane in RandomGenerator and Tutorial (see fastlane/Fastfile)
  • Introduced Fastlane and shared it between private pods

Testing

In order to cover whole development flow, I really want to touch testing a bit.

  • Setup Scanfiles to automate testing with Fastlane (see fastlane/Scanfile)
  • Setup private pod examples to gather coverage data
  • Setup Slather to format coverage data for reports on CI
  • Setup testing and coverage in private pods

Summary

As a result of this workshop we were able to create iOS project with some parts of its functionality split into modules using CocoaPods. First, we were developing modules in local pods. However later we extracted them in private pods and started managing our own specs repo. We solved issue with sharing automation scripts between private pods using Fastlane. And we setup testing and coverage using Fastlane Scan and Slather.


Tips & Tricks

  • Set optimization to None when you want to debug Pod
  • pod update YourPod --no-repo-update when you want to force update pod without loooong repo update (helps to quickly update pod locally)
  • Include private pod as a local pod (using path key and relative or absolute path to it in Podfile) if you need to hot-patch or play around with it, but want to save changes