"i have a framework idea" - repeat less, share more

80
'' I HAVE A FRAMEWORK IDEA '' REPEAT LESS, SHARE MORE. FABIO MILANO - @IAMFABIOMILANO

Upload: fabio-milano

Post on 16-Apr-2017

708 views

Category:

Technology


2 download

TRANSCRIPT

Page 1: "I have a framework idea" - Repeat less, share more

'' I HAVE A FRAMEWORK IDEA ''REPEAT LESS, SHARE MORE.

FABIO MILANO - @IAMFABIOMILANO

Page 2: "I have a framework idea" - Repeat less, share more

I have an app idea.— Someone, somewhere.

Page 3: "I have a framework idea" - Repeat less, share more

WHATIS A FRAMEWORK?

Page 4: "I have a framework idea" - Repeat less, share more

WHAT IS INSIDE A FRAMEWORK?

...

Page 5: "I have a framework idea" - Repeat less, share more

WHYFRAMEWORKS?

Page 6: "I have a framework idea" - Repeat less, share more
Page 7: "I have a framework idea" - Repeat less, share more
Page 8: "I have a framework idea" - Repeat less, share more
Page 9: "I have a framework idea" - Repeat less, share more
Page 10: "I have a framework idea" - Repeat less, share more
Page 11: "I have a framework idea" - Repeat less, share more

!

Page 12: "I have a framework idea" - Repeat less, share more
Page 13: "I have a framework idea" - Repeat less, share more

WHYFRAMEWORKS?

Page 14: "I have a framework idea" - Repeat less, share more

WITH A FRAMEWORK

Page 15: "I have a framework idea" - Repeat less, share more

SHARING IS CARING

Page 16: "I have a framework idea" - Repeat less, share more

> separation of concerns

Page 17: "I have a framework idea" - Repeat less, share more

> separation of concerns *

* It might affect app launch time (use DYLD_PRINT_STATISTICS for stats).

Page 18: "I have a framework idea" - Repeat less, share more

> separation of concerns> encapsulation

Page 19: "I have a framework idea" - Repeat less, share more

> separation of concerns> encapsulation> maintanability

Page 20: "I have a framework idea" - Repeat less, share more

CREATE A FRAMEWORK

Page 21: "I have a framework idea" - Repeat less, share more

CREATE A FRAMEWORK

Page 22: "I have a framework idea" - Repeat less, share more

THE FOLDER STRUCTURE

Page 23: "I have a framework idea" - Repeat less, share more

THE FOLDER STRUCTUREexample-package-awesome-library!"" Sources# !"" AwesomeStruct.swift# !"" AwesomeClass.swift# $"" AwesomeProtocol.swift|"" Tests # !"" AwesomeTests# | !"" AwesomeClassTest.swift

Page 24: "I have a framework idea" - Repeat less, share more

DONE! !

Page 25: "I have a framework idea" - Repeat less, share more

..ALMOST..

Page 26: "I have a framework idea" - Repeat less, share more
Page 27: "I have a framework idea" - Repeat less, share more

CREATE FRAMEWORKTHE PLATFORMS

Page 28: "I have a framework idea" - Repeat less, share more

MULTI PLATFORM TESTS

Page 29: "I have a framework idea" - Repeat less, share more

!

Page 30: "I have a framework idea" - Repeat less, share more

Page 31: "I have a framework idea" - Repeat less, share more

THE BUILD SETTINGSSUPPORTED PLATFORMS

Page 32: "I have a framework idea" - Repeat less, share more

THE BUILD SETTINGSSUPPORTED PLATFORMS

Page 33: "I have a framework idea" - Repeat less, share more

THE BUILD SETTINGSTARGETED DEVICE FAMILY

Page 34: "I have a framework idea" - Repeat less, share more

THE .xcconfig FILE

Page 35: "I have a framework idea" - Repeat less, share more
Page 36: "I have a framework idea" - Repeat less, share more

THE STRANGE CASE OF TARGETED_DEVICE_FAMILY

// Config.xcconfig

TARGETED_DEVICE_FAMILY = 1,2,3,4

Page 37: "I have a framework idea" - Repeat less, share more
Page 38: "I have a framework idea" - Repeat less, share more

THE BUILD SETTINGSTHE DEPLOYMENT TARGET

Page 39: "I have a framework idea" - Repeat less, share more

/**Authorize by requesting a device code.

- Parameters: - completion: The completion block. - String: The device code to use to finish the authorization flow.

- see: https://tools.ietf.org/html/draft-denniss-oauth-device-flow-00*/public func authorizeViaDeviceCode(completion: (String) -> Void) throws { ... }

#if os(iOS) || os(OSX)

import WebKit

/**Authorize via standard OAuth 2.0 authorization flow.

- Parameters: - completion: The completion block. - WKWebView: The web page where the user can authorize the application.*/public func authorize(completion: (WKWebView) -> Void) throws { ... }#endif

Page 40: "I have a framework idea" - Repeat less, share more

THE BUILD SETTINGSRUN PATH SEARCH PATHS (A.K.A rpath)

Page 41: "I have a framework idea" - Repeat less, share more

PLAYGROUND:A PLACE WHERE PEOPLE CAN PLAY

Page 42: "I have a framework idea" - Repeat less, share more
Page 43: "I have a framework idea" - Repeat less, share more
Page 44: "I have a framework idea" - Repeat less, share more
Page 45: "I have a framework idea" - Repeat less, share more

DEPENDENCY MANAGERS

Page 46: "I have a framework idea" - Repeat less, share more

COCOAPODS

Page 47: "I have a framework idea" - Repeat less, share more
Page 48: "I have a framework idea" - Repeat less, share more

COCOAPODS - HOW

pod spec create MyAwesomeKit

Page 49: "I have a framework idea" - Repeat less, share more

COCOAPODS - PODSPEC FILEPod::Spec.new do |spec| spec.name = 'MyAwesomeKit' spec.version = '0.1.0' spec.license = { :type => 'MIT' } spec.homepage = 'https://pragmaconference.com' spec.authors = { 'You' => '[email protected]' } spec.summary = 'Awesome code that works for your platform.' spec.source = .... spec.source_files = .... spec.framework = 'SystemConfiguration'

spec.ios.deployment_target = '10.0' spec.watchos.deployment_target = '3.0' spec.tvos.deployment_target = '10.0' spec.osx.deployment_target = '10.12'

spec.dependency "Result", "~> 2.1"end

Page 50: "I have a framework idea" - Repeat less, share more

CARTHAGE

Page 51: "I have a framework idea" - Repeat less, share more
Page 52: "I have a framework idea" - Repeat less, share more

CARTHAGE# Cartfile

github "ReactiveCocoa/ReactiveCocoa" # GitHub.comgithub "https://enterprise.local/ghe/desktop/git-error-translations" # GitHub Enterprise

git "https://enterprise.local/desktop/git-error-translations2.git"

Page 53: "I have a framework idea" - Repeat less, share more

CARTHAGE# Cartfile.private

github "Quick/Quick"github "Quick/Nimble"

Page 54: "I have a framework idea" - Repeat less, share more

carthage update

Page 55: "I have a framework idea" - Repeat less, share more

xcconfig FILE ..AND CARTHAGE

// Carthage.xcconfig

#include "MyAwesomeConfig.xcconfig"

FRAMEWORK_SEARCH_PATHS[sdk=macosx*] = $(SRCROOT)/Carthage/Build/Mac/ $(inherited)FRAMEWORK_SEARCH_PATHS[sdk=iphone*] = $(SRCROOT)/Carthage/Build/iOS/ $(inherited)FRAMEWORK_SEARCH_PATHS[sdk=watch*] = $(SRCROOT)/Carthage/Build/watchOS/ $(inherited)FRAMEWORK_SEARCH_PATHS[sdk=appletv*] = $(SRCROOT)/Carthage/Build/tvOS/ $(inherited)

Page 56: "I have a framework idea" - Repeat less, share more
Page 57: "I have a framework idea" - Repeat less, share more

SWIFT PACKAGE MANAGER (SPM)

Page 58: "I have a framework idea" - Repeat less, share more

SPM - THE PACKAGE FILE1

import PackageDescription

let package = Package( name: "SwiftBackend", dependencies: [ .Package(url: "https://github.com/PerfectlySoft/Perfect-HTTPServer.git", majorVersion: 2, minor: 0 ), .Package(url: "https://github.com/PerfectlySoft/Perfect-PostgreSQL.git", majorVersion: 2, minor: 0) ])

1 Example from Perfect: Server-Side Swift project.

Page 59: "I have a framework idea" - Repeat less, share more

$ swift build

$ swift test

Page 60: "I have a framework idea" - Repeat less, share more

SPM... AND XCODE

swift package generate-xcodeproj

Page 61: "I have a framework idea" - Repeat less, share more

BEING A LIBRARY

Page 62: "I have a framework idea" - Repeat less, share more

CONTINUOUS INTEGRATION

Page 63: "I have a framework idea" - Repeat less, share more

CONTINUOUS INTEGRATION

> catching probelms quickly, easily and early

Page 64: "I have a framework idea" - Repeat less, share more

CONTINUOUS INTEGRATION

> catching probelms quickly, easily and early> enhancing collaboration

Page 65: "I have a framework idea" - Repeat less, share more

CONTINUOUS INTEGRATION

> catching probelms quickly, easily and early> enhancing collaboration> broadening test coverage

Page 66: "I have a framework idea" - Repeat less, share more

TRAVIS CI

Page 67: "I have a framework idea" - Repeat less, share more

# .travis.yml

language: objective-cosx_image: xcode8

script: - xcodebuild test -workspace MyAwesomeFramework.xcworkspace -scheme MyAwesomeFramework-Mac - xcodebuild test -workspace MyAwesomeFramework.xcworkspace -scheme MyAwesomeFramework-iOS -sdk iphonesimulator - xcodebuild test -workspace MyAwesomeFramework.xcworkspace -scheme MyAwesomeFramework-tvOS -sdk appletvsimulator - xcodebuild build -workspace MyAwesomeFramework.xcworkspace -scheme MyAwesomeFramework-watchOS -sdk watchsimulator

Page 68: "I have a framework idea" - Repeat less, share more

# .travis.yml

language: objective-cosx_image: xcode8

env: - ACTION=test PLATFORM=Mac DESTINATION='platform=OS X' - ACTION=test PLATFORM=iOS DESTINATION='platform=iOS Simulator,name=iPhone 6S' - ACTION=build PLATFORM=watchOS DESTINATION='platform=watchOS Simulator,name=Apple Watch - 38mm' - ACTION=test PLATFORM=tvOS DESTINATION='platform=tvOS Simulator,name=Apple TV 1080p'

script: - set -o pipefail && xcodebuild -scheme MyAwesomeFramework -destination "$DESTINATION" $ACTION | xcpretty

Page 69: "I have a framework idea" - Repeat less, share more
Page 70: "I have a framework idea" - Repeat less, share more

DANGER FILE2

# Sometimes it's a README fix, or something like that - which isn't relevant for# including in a project's CHANGELOG for examplenot_declared_trivial = !(github.pr_title.include? "#trivial")has_app_changes = !git.modified_files.grep(/Source/).empty?

# Make it more obvious that a PR is a work in progress and shouldn't be merged yetwarn("PR is classed as Work in Progress") if github.pr_title.include? "[WIP]"

# Warn when there is a big PRwarn("Big PR") if git.lines_of_code > 500

# Changelog entries are required for changes to library files.no_changelog_entry = !git.modified_files.include?("Changelog.md")if has_app_changes && no_changelog_entry && not_declared_trivial fail("Any changes to library code need a summary in the Changelog.")end

# Added (or removed) library files need to be added (or removed) from the# Carthage Xcode project to avoid breaking things for our Carthage users.added_swift_library_files = git.added_files.grep(/Source.*\.swift/).empty?deleted_swift_library_files = git.deleted_files.grep(/Source.*\.swift/).empty?modified_carthage_xcode_project = !(git.deleted_files.grep(/Moya\.xcodeproj/).empty?)if (added_swift_library_files || deleted_swift_library_files) && modified_carthage_xcode_project fail("Added or removed library files require the Carthage Xcode project to be updated.")end

2 Example from https://github.com/Moya/Moya/blob/master/Dangerfile

Page 71: "I have a framework idea" - Repeat less, share more

DANGER

Page 72: "I have a framework idea" - Repeat less, share more

!

Page 73: "I have a framework idea" - Repeat less, share more

0 . 1 . 0

Page 74: "I have a framework idea" - Repeat less, share more

1 . 0 . 0

Page 75: "I have a framework idea" - Repeat less, share more

RECAP

Page 76: "I have a framework idea" - Repeat less, share more

RECAP

> framework or not framework?

Page 77: "I have a framework idea" - Repeat less, share more

RECAP

> framework or not framework?> platform matters

Page 78: "I have a framework idea" - Repeat less, share more

RECAP

> framework or not framework?> platform matters

> automate, automate, automate!

Page 79: "I have a framework idea" - Repeat less, share more

RECAP

> framework or not framework?> platform matters

> automate, automate, automate!> open source

Page 80: "I have a framework idea" - Repeat less, share more

THANK YOU!