Slide 1

Slide 1 text

S F S F D D Xavier Rubio Jansana  @teknik_tdr  https://xrubio.com  https://github.com/xrubioj/

Slide 2

Slide 2 text

W ? W ? A framework is a collection of... ...code ...assets ...images ...more

Slide 3

Slide 3 text

F != F != Dynamic vs static Bundle vs just code

Slide 4

Slide 4 text

P P Allows reutilization Favors encapsulation Favors defining boundaries

Slide 5

Slide 5 text

C C Harder to maintain Harder to prototype ↔ architect Slower iteration

Slide 6

Slide 6 text

H ? H ? Manual + git submodules... Carthage CocoaPods Swi Package Manager

Slide 7

Slide 7 text

M M Completely manual (download or copy) Git submodules ⚠ Detached heads ✅ Exact point in time In both cases, manual integration

Slide 8

Slide 8 text

C C Not centralized Manual steps More control

Slide 9

Slide 9 text

C P C P Well known Automated Less control ("blackbox")

Slide 10

Slide 10 text

S P S P M M New, less support Server projects

Slide 11

Slide 11 text

C P C P

Slide 12

Slide 12 text

P P .bash_profile / .zshrc / ... Installing export GEM_HOME=$HOME/.gem export PATH=$GEM_HOME/bin:$PATH $ gem install cocoapods --user-install

Slide 13

Slide 13 text

B B $ pod init $ pod install $ pod update $ pod outdated

Slide 14

Slide 14 text

P P platform :ios, '9.0' target 'MyApp' do use_frameworks! pod 'Alamofire', '~> 4.5.0' target 'MyAppTests' do inherit! :search_paths end end

Slide 15

Slide 15 text

S S PATCH: bugfixes, doesn't add features MINOR: new features, no breaking changes MAJOR: breaking changes MAJOR.MINOR.PATCH semver.org

Slide 16

Slide 16 text

S S Exact version  0.1 Comparators  > 0.1  >= 0.1  < 0.1  <= 0.1 Optimistic comparator  ~> 0.1.2  ~> 0.1

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

M C P M C P

Slide 19

Slide 19 text

P P $ pod spec create Lipsum Specification created at Lipsum.podspec $

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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.

Slide 23

Slide 23 text

$ open SampleLipsumApp.xcworkspace

Slide 24

Slide 24 text

H H Remember public Development Pods pod update not needed

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

Q ? Q ?

Slide 30

Slide 30 text

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/