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

Swifty Framework Development for pragmatic deve...

Swifty Framework Development for pragmatic developers

Xavier Rubio Jansana

January 24, 2018
Tweet

More Decks by Xavier Rubio Jansana

Other Decks in Programming

Transcript

  1. S F S F D D Xavier Rubio Jansana 

    @teknik_tdr  https://xrubio.com  https://github.com/xrubioj/
  2. W ? W ? A framework is a collection of...

    ...code ...assets ...images ...more
  3. M M Completely manual (download or copy) Git submodules ⚠

    Detached heads ✅ Exact point in time In both cases, manual integration
  4. P P .bash_profile / .zshrc / ... Installing export GEM_HOME=$HOME/.gem

    export PATH=$GEM_HOME/bin:$PATH $ gem install cocoapods --user-install
  5. B B $ pod init $ pod install $ pod

    update $ pod outdated
  6. P P platform :ios, '9.0' target 'MyApp' do use_frameworks! pod

    'Alamofire', '~> 4.5.0' target 'MyAppTests' do inherit! :search_paths end end
  7. S S PATCH: bugfixes, doesn't add features MINOR: new features,

    no breaking changes MAJOR: breaking changes MAJOR.MINOR.PATCH semver.org
  8. S S Exact version  0.1 Comparators  > 0.1  >= 0.1 

    < 0.1  <= 0.1 Optimistic comparator  ~> 0.1.2  ~> 0.1
  9. P . P . Allows pinning versions → reproducible builds

    Add it to the repo Alternatively, add Pods directory Using exact versions in the Podfile is not enough
  10. P P Pod::Spec.new do |s| s.name = "Lipsum" s.version =

    "0.0.1" s.summary = "Simple Lorem Ipsum generator framework example." s.description = <<-DESC Simple Lorem Ipsum generator to support the talk Swify Framework Development for pragmatic developers. DESC s.homepage = "http://xrubio.com/talks" s.license = { :type => "MIT", :file => "LICENSE" } s.author = "Xavier Rubio Jansana" s.social_media_url = "http://twitter.com/teknik_tdr" s.platform = :ios, "9.0" s.source = { :git => "https://github.com/xrubioj/swifty-framework-Lipsum.git", :tag => "#{s.version}" } s.source_files = "Lipsum", "Lipsum/**/*.{h,m,swift}" end
  11. U P U P platform :ios, '9.0' target 'SampleLipsumApp' do

    use_frameworks! pod 'Lipsum', :path => '../Lipsum' #target 'SampleLipsumAppTests' do # inherit! :search_paths #end end
  12. L ' ! L ' ! $ pod install Analyzing

    dependencies Fetching podspec for `Lipsum` from `../Lipsum` Downloading dependencies Installing Lipsum (0.0.1) Generating Pods project Integrating client project [!] Please close any current Xcode sessions and use `SampleLipsumApp.xcworkspace` for this project from now on. Sending stats Pod installation complete! There is 1 dependency from the Podfile and 1 total pod installed.
  13. P P Create framework project Create podspec echo "4.0" >

    .swift-version pod lib lint Commit and push to repo Tag with version ("0.0.1") and push pod trunk push Lipsum.podspec --allow-warnings
  14. N N Run tests Update podspec (version!) pod lib lint

    Commit and push to repo Tag with new version ("0.0.2") and push pod trunk push Lipsum.podspec --allow-warnings
  15. P P P P Create a git repo Add: pod

    repo add private-repo https://github.com/xrubioj/swifty- framework-private-repo.git Push Podspec: pod repo push private-repo Lipsum.podspec Update your Podfile with source
  16. U P U P platform :ios, '9.0' source 'https://github.com/CocoaPods/Specs.git' source

    'https://github.com/xrubioj/swifty-framework-private-repo.git' target 'SampleLipsumApp' do use_frameworks! pod 'Lipsum', '~> 0.0.1' #target 'SampleLipsumAppTests' do # inherit! :search_paths #end end
  17. Swi y Framework Development for pragmatic developers T ! T

    ! Xavier Rubio Jansana This talk is available at:  @teknik_tdr  https://xrubio.com  https://github.com/xrubioj/ https://xrubio.com/talks/talk-swi y-frameworks/