"I have a framework idea" - Repeat less, share more.

Fabio Milano
Fabio MilanoiOS Lead at Loot
'' I HAVE A FRAMEWORK IDEA ''
REPEAT LESS, SHARE MORE.
FABIO MILANO - @IAMFABIOMILANO
I have an app idea.
— Someone, somewhere.
WHAT
IS A FRAMEWORK?
WHAT IS INSIDE A FRAMEWORK?
...
WHY
FRAMEWORKS?
"I have a framework idea" - Repeat less, share more.
"I have a framework idea" - Repeat less, share more.
"I have a framework idea" - Repeat less, share more.
"I have a framework idea" - Repeat less, share more.
"I have a framework idea" - Repeat less, share more.
!
"I have a framework idea" - Repeat less, share more.
WHY
FRAMEWORKS?
WITH A FRAMEWORK
SHARING IS
CARING
> separation of concerns
> separation of concerns *
*
It might affect app launch time (use DYLD_PRINT_STATISTICS for stats).
> separation of concerns
> encapsulation
> separation of concerns
> encapsulation
> maintanability
CREATE A FRAMEWORK
CREATE A FRAMEWORK
THE FOLDER
STRUCTURE
THE FOLDER STRUCTURE
example-package-awesome-library
!"" Sources
# !"" AwesomeStruct.swift
# !"" AwesomeClass.swift
# $"" AwesomeProtocol.swift
|"" Tests
# !"" AwesomeTests
# | !"" AwesomeClassTest.swift
DONE! !
..ALMOST..
"I have a framework idea" - Repeat less, share more.
CREATE FRAMEWORK
THE PLATFORMS
MULTI PLATFORM TESTS
!
⚠
THE BUILD SETTINGS
SUPPORTED PLATFORMS
THE BUILD SETTINGS
SUPPORTED PLATFORMS
THE BUILD SETTINGS
TARGETED DEVICE FAMILY
THE .xcconfig FILE
"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
"I have a framework idea" - Repeat less, share more.
THE BUILD SETTINGS
THE DEPLOYMENT TARGET
/**
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
THE BUILD SETTINGS
RUN PATH SEARCH PATHS (A.K.A rpath)
PLAYGROUND:
A PLACE WHERE PEOPLE CAN PLAY
"I have a framework idea" - Repeat less, share more.
"I have a framework idea" - Repeat less, share more.
"I have a framework idea" - Repeat less, share more.
DEPENDENCY
MANAGERS
COCOAPODS
"I have a framework idea" - Repeat less, share more.
COCOAPODS - HOW
pod spec create MyAwesomeKit
COCOAPODS - PODSPEC FILE
Pod::Spec.new do |spec|
spec.name = 'MyAwesomeKit'
spec.version = '0.1.0'
spec.license = { :type => 'MIT' }
spec.homepage = 'https://pragmaconference.com'
spec.authors = { 'You' => 'you@me.com' }
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
CARTHAGE
"I have a framework idea" - Repeat less, share more.
CARTHAGE
# Cartfile
github "ReactiveCocoa/ReactiveCocoa" # GitHub.com
github "https://enterprise.local/ghe/desktop/git-error-translations" # GitHub Enterprise
git "https://enterprise.local/desktop/git-error-translations2.git"
CARTHAGE
# Cartfile.private
github "Quick/Quick"
github "Quick/Nimble"
carthage update
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)
"I have a framework idea" - Repeat less, share more.
SWIFT PACKAGE
MANAGER (SPM)
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.
$ swift build
$ swift test
SPM... AND XCODE
swift package generate-xcodeproj
BEING A
LIBRARY
CONTINUOUS
INTEGRATION
CONTINUOUS INTEGRATION
> catching probelms quickly, easily and early
CONTINUOUS INTEGRATION
> catching probelms quickly, easily and early
> enhancing collaboration
CONTINUOUS INTEGRATION
> catching probelms quickly, easily and early
> enhancing collaboration
> broadening test coverage
TRAVIS CI
# .travis.yml
language: objective-c
osx_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
# .travis.yml
language: objective-c
osx_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
"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 example
not_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 yet
warn("PR is classed as Work in Progress") if github.pr_title.include? "[WIP]"
# Warn when there is a big PR
warn("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
DANGER
!
0 . 1 . 0
1 . 0 . 0
RECAP
RECAP
> framework or not framework?
RECAP
> framework or not framework?
> platform matters
RECAP
> framework or not framework?
> platform matters
> automate, automate, automate!
RECAP
> framework or not framework?
> platform matters
> automate, automate, automate!
> open source
THANK YOU!
1 of 80

Recommended

Deploy your app with one Slack command by
Deploy your app with one Slack commandDeploy your app with one Slack command
Deploy your app with one Slack commandFabio Milano
655 views28 slides
Fastlane - Automation and Continuous Delivery for iOS Apps by
Fastlane - Automation and Continuous Delivery for iOS AppsFastlane - Automation and Continuous Delivery for iOS Apps
Fastlane - Automation and Continuous Delivery for iOS AppsSarath C
1.1K views88 slides
React Ecosystem by
React EcosystemReact Ecosystem
React EcosystemCraig Jolicoeur
461 views20 slides
Calabash Andoird + Calabash iOS by
Calabash Andoird + Calabash iOSCalabash Andoird + Calabash iOS
Calabash Andoird + Calabash iOSAnadea
576 views25 slides
Android + jenkins by
Android + jenkinsAndroid + jenkins
Android + jenkinsFred Lin
9.4K views54 slides
Jazoon12 355 aleksandra_gavrilovska-1 by
Jazoon12 355 aleksandra_gavrilovska-1Jazoon12 355 aleksandra_gavrilovska-1
Jazoon12 355 aleksandra_gavrilovska-1Netcetera
1.6K views17 slides

More Related Content

What's hot

Intro to Eclipse Che, by Tyler Jewell by
Intro to Eclipse Che, by Tyler JewellIntro to Eclipse Che, by Tyler Jewell
Intro to Eclipse Che, by Tyler Jewelljwi11iams
4.8K views22 slides
CocoaHeads Rennes #13 : CocoaPods by
CocoaHeads Rennes #13 : CocoaPodsCocoaHeads Rennes #13 : CocoaPods
CocoaHeads Rennes #13 : CocoaPodsCocoaHeadsRNS
5K views11 slides
Calabash my understanding by
Calabash my understandingCalabash my understanding
Calabash my understandingFARHAN SUMBUL
4.5K views4 slides
Continuous Integration for your Android projects by
Continuous Integration for your Android projectsContinuous Integration for your Android projects
Continuous Integration for your Android projectsSergii Zhuk
3.5K views26 slides
Fastlane by
FastlaneFastlane
FastlaneWarren Lin
525 views26 slides
iOS and Android Acceptance Testing with Calabash - Xcake Dublin by
iOS and Android Acceptance Testing with Calabash - Xcake DubliniOS and Android Acceptance Testing with Calabash - Xcake Dublin
iOS and Android Acceptance Testing with Calabash - Xcake Dublinroland99
1.3K views64 slides

What's hot(20)

Intro to Eclipse Che, by Tyler Jewell by jwi11iams
Intro to Eclipse Che, by Tyler JewellIntro to Eclipse Che, by Tyler Jewell
Intro to Eclipse Che, by Tyler Jewell
jwi11iams4.8K views
CocoaHeads Rennes #13 : CocoaPods by CocoaHeadsRNS
CocoaHeads Rennes #13 : CocoaPodsCocoaHeads Rennes #13 : CocoaPods
CocoaHeads Rennes #13 : CocoaPods
CocoaHeadsRNS5K views
Calabash my understanding by FARHAN SUMBUL
Calabash my understandingCalabash my understanding
Calabash my understanding
FARHAN SUMBUL4.5K views
Continuous Integration for your Android projects by Sergii Zhuk
Continuous Integration for your Android projectsContinuous Integration for your Android projects
Continuous Integration for your Android projects
Sergii Zhuk3.5K views
iOS and Android Acceptance Testing with Calabash - Xcake Dublin by roland99
iOS and Android Acceptance Testing with Calabash - Xcake DubliniOS and Android Acceptance Testing with Calabash - Xcake Dublin
iOS and Android Acceptance Testing with Calabash - Xcake Dublin
roland991.3K views
Scale your PHP application with Elastic Beanstalk - CloudParty Genova by Corley S.r.l.
Scale your PHP application with Elastic Beanstalk - CloudParty GenovaScale your PHP application with Elastic Beanstalk - CloudParty Genova
Scale your PHP application with Elastic Beanstalk - CloudParty Genova
Corley S.r.l.2.8K views
Deploying ASP.Net Core apps in Docker Containers by Amal Dev
Deploying ASP.Net Core apps in Docker ContainersDeploying ASP.Net Core apps in Docker Containers
Deploying ASP.Net Core apps in Docker Containers
Amal Dev1.1K views
Accessors Vs Direct access to properties & Design Pattern by CocoaHeads France
Accessors Vs Direct access to properties & Design PatternAccessors Vs Direct access to properties & Design Pattern
Accessors Vs Direct access to properties & Design Pattern
CocoaHeads France4.2K views
Ci system part i by 振維 李
Ci system part iCi system part i
Ci system part i
振維 李1.1K views
Automate your build on Android with Jenkins by BeMyApp
Automate your build on Android with JenkinsAutomate your build on Android with Jenkins
Automate your build on Android with Jenkins
BeMyApp2.3K views
Building Rich Applications with Appcelerator by Matt Raible
Building Rich Applications with AppceleratorBuilding Rich Applications with Appcelerator
Building Rich Applications with Appcelerator
Matt Raible2.6K views
Building the Test Automation Framework - Jenkins for Testers by William Echlin
Building the Test Automation Framework - Jenkins for TestersBuilding the Test Automation Framework - Jenkins for Testers
Building the Test Automation Framework - Jenkins for Testers
William Echlin2.3K views
Automation Testing by RomSoft SRL
Automation TestingAutomation Testing
Automation Testing
RomSoft SRL1.5K views
Continuous Delivery Using Jenkins by Cliffano Subagio
Continuous Delivery Using JenkinsContinuous Delivery Using Jenkins
Continuous Delivery Using Jenkins
Cliffano Subagio3.6K views
Continuous integration using jenkins by Vinay H G
Continuous integration using jenkinsContinuous integration using jenkins
Continuous integration using jenkins
Vinay H G1.5K views

Similar to "I have a framework idea" - Repeat less, share more.

BP-6 Repository Customization Best Practices by
BP-6 Repository Customization Best PracticesBP-6 Repository Customization Best Practices
BP-6 Repository Customization Best PracticesAlfresco Software
1.2K views36 slides
Lean Php Presentation by
Lean Php PresentationLean Php Presentation
Lean Php PresentationAlan Pinstein
13.7K views21 slides
Gigigo Workshop - Create an iOS Framework, document it and not die trying by
Gigigo Workshop - Create an iOS Framework, document it and not die tryingGigigo Workshop - Create an iOS Framework, document it and not die trying
Gigigo Workshop - Create an iOS Framework, document it and not die tryingAlex Rupérez
42.2K views14 slides
TYPO3 Extension development using new Extbase framework by
TYPO3 Extension development using new Extbase frameworkTYPO3 Extension development using new Extbase framework
TYPO3 Extension development using new Extbase frameworkChristian Trabold
5.2K views81 slides
Phing by
PhingPhing
Phingmdekrijger
3K views15 slides
IzPack at LyonJUG'11 by
IzPack at LyonJUG'11IzPack at LyonJUG'11
IzPack at LyonJUG'11julien.ponge
1.4K views66 slides

Similar to "I have a framework idea" - Repeat less, share more.(20)

BP-6 Repository Customization Best Practices by Alfresco Software
BP-6 Repository Customization Best PracticesBP-6 Repository Customization Best Practices
BP-6 Repository Customization Best Practices
Alfresco Software1.2K views
Lean Php Presentation by Alan Pinstein
Lean Php PresentationLean Php Presentation
Lean Php Presentation
Alan Pinstein13.7K views
Gigigo Workshop - Create an iOS Framework, document it and not die trying by Alex Rupérez
Gigigo Workshop - Create an iOS Framework, document it and not die tryingGigigo Workshop - Create an iOS Framework, document it and not die trying
Gigigo Workshop - Create an iOS Framework, document it and not die trying
Alex Rupérez42.2K views
TYPO3 Extension development using new Extbase framework by Christian Trabold
TYPO3 Extension development using new Extbase frameworkTYPO3 Extension development using new Extbase framework
TYPO3 Extension development using new Extbase framework
Christian Trabold5.2K views
IzPack at LyonJUG'11 by julien.ponge
IzPack at LyonJUG'11IzPack at LyonJUG'11
IzPack at LyonJUG'11
julien.ponge1.4K views
Dependencies Managers in C/C++. Using stdcpp 2014 by biicode
Dependencies Managers in C/C++. Using stdcpp 2014Dependencies Managers in C/C++. Using stdcpp 2014
Dependencies Managers in C/C++. Using stdcpp 2014
biicode4.4K views
Burn down the silos! Helping dev and ops gel on high availability websites by Lindsay Holmwood
Burn down the silos! Helping dev and ops gel on high availability websitesBurn down the silos! Helping dev and ops gel on high availability websites
Burn down the silos! Helping dev and ops gel on high availability websites
Lindsay Holmwood1.6K views
Automatisation in development and testing - within budget by David Lukac
Automatisation in development and testing - within budgetAutomatisation in development and testing - within budget
Automatisation in development and testing - within budget
David Lukac220 views
Everything is Awesome - Cutting the Corners off the Web by James Rakich
Everything is Awesome - Cutting the Corners off the WebEverything is Awesome - Cutting the Corners off the Web
Everything is Awesome - Cutting the Corners off the Web
James Rakich544 views
Modular Test-driven SPAs with Spring and AngularJS by Gunnar Hillert
Modular Test-driven SPAs with Spring and AngularJSModular Test-driven SPAs with Spring and AngularJS
Modular Test-driven SPAs with Spring and AngularJS
Gunnar Hillert3.8K views
One Click Provisioning With Enterprise Manager 12c by Josh Turner
One Click Provisioning With Enterprise Manager 12cOne Click Provisioning With Enterprise Manager 12c
One Click Provisioning With Enterprise Manager 12c
Josh Turner306 views
vJUG - The JavaFX Ecosystem by Andres Almiray
vJUG - The JavaFX EcosystemvJUG - The JavaFX Ecosystem
vJUG - The JavaFX Ecosystem
Andres Almiray3.6K views
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe) by mfrancis
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
mfrancis320 views
Buildr In Action @devoxx france 2012 by alexismidon
Buildr In Action @devoxx france 2012Buildr In Action @devoxx france 2012
Buildr In Action @devoxx france 2012
alexismidon2.4K views

Recently uploaded

Microsoft Power Platform.pptx by
Microsoft Power Platform.pptxMicrosoft Power Platform.pptx
Microsoft Power Platform.pptxUni Systems S.M.S.A.
53 views38 slides
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ... by
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...Jasper Oosterveld
18 views49 slides
Melek BEN MAHMOUD.pdf by
Melek BEN MAHMOUD.pdfMelek BEN MAHMOUD.pdf
Melek BEN MAHMOUD.pdfMelekBenMahmoud
14 views1 slide
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Safe Software
263 views86 slides
STPI OctaNE CoE Brochure.pdf by
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdfmadhurjyapb
14 views1 slide
Network Source of Truth and Infrastructure as Code revisited by
Network Source of Truth and Infrastructure as Code revisitedNetwork Source of Truth and Infrastructure as Code revisited
Network Source of Truth and Infrastructure as Code revisitedNetwork Automation Forum
26 views45 slides

Recently uploaded(20)

ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ... by Jasper Oosterveld
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
Igniting Next Level Productivity with AI-Infused Data Integration Workflows by Safe Software
Igniting Next Level Productivity with AI-Infused Data Integration Workflows Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Safe Software263 views
STPI OctaNE CoE Brochure.pdf by madhurjyapb
STPI OctaNE CoE Brochure.pdfSTPI OctaNE CoE Brochure.pdf
STPI OctaNE CoE Brochure.pdf
madhurjyapb14 views
Transcript: The Details of Description Techniques tips and tangents on altern... by BookNet Canada
Transcript: The Details of Description Techniques tips and tangents on altern...Transcript: The Details of Description Techniques tips and tangents on altern...
Transcript: The Details of Description Techniques tips and tangents on altern...
BookNet Canada136 views
Case Study Copenhagen Energy and Business Central.pdf by Aitana
Case Study Copenhagen Energy and Business Central.pdfCase Study Copenhagen Energy and Business Central.pdf
Case Study Copenhagen Energy and Business Central.pdf
Aitana16 views
Five Things You SHOULD Know About Postman by Postman
Five Things You SHOULD Know About PostmanFive Things You SHOULD Know About Postman
Five Things You SHOULD Know About Postman
Postman33 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson85 views
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院 by IttrainingIttraining
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
【USB韌體設計課程】精選講義節錄-USB的列舉過程_艾鍗學院
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas... by Bernd Ruecker
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
iSAQB Software Architecture Gathering 2023: How Process Orchestration Increas...
Bernd Ruecker37 views
Unit 1_Lecture 2_Physical Design of IoT.pdf by StephenTec
Unit 1_Lecture 2_Physical Design of IoT.pdfUnit 1_Lecture 2_Physical Design of IoT.pdf
Unit 1_Lecture 2_Physical Design of IoT.pdf
StephenTec12 views
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive by Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive

"I have a framework idea" - Repeat less, share more.

  • 1. '' I HAVE A FRAMEWORK IDEA '' REPEAT LESS, SHARE MORE. FABIO MILANO - @IAMFABIOMILANO
  • 2. I have an app idea. — Someone, somewhere.
  • 4. WHAT IS INSIDE A FRAMEWORK? ...
  • 11. !
  • 16. > separation of concerns
  • 17. > separation of concerns * * It might affect app launch time (use DYLD_PRINT_STATISTICS for stats).
  • 18. > separation of concerns > encapsulation
  • 19. > separation of concerns > encapsulation > maintanability
  • 23. THE FOLDER STRUCTURE example-package-awesome-library !"" Sources # !"" AwesomeStruct.swift # !"" AwesomeClass.swift # $"" AwesomeProtocol.swift |"" Tests # !"" AwesomeTests # | !"" AwesomeClassTest.swift
  • 29. !
  • 30.
  • 36. THE STRANGE CASE OF TARGETED_DEVICE_FAMILY // Config.xcconfig TARGETED_DEVICE_FAMILY = 1,2,3,4
  • 38. THE BUILD SETTINGS THE DEPLOYMENT TARGET
  • 39. /** 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
  • 40. THE BUILD SETTINGS RUN PATH SEARCH PATHS (A.K.A rpath)
  • 41. PLAYGROUND: A PLACE WHERE PEOPLE CAN PLAY
  • 48. COCOAPODS - HOW pod spec create MyAwesomeKit
  • 49. COCOAPODS - PODSPEC FILE Pod::Spec.new do |spec| spec.name = 'MyAwesomeKit' spec.version = '0.1.0' spec.license = { :type => 'MIT' } spec.homepage = 'https://pragmaconference.com' spec.authors = { 'You' => 'you@me.com' } 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
  • 52. CARTHAGE # Cartfile github "ReactiveCocoa/ReactiveCocoa" # GitHub.com github "https://enterprise.local/ghe/desktop/git-error-translations" # GitHub Enterprise git "https://enterprise.local/desktop/git-error-translations2.git"
  • 55. 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)
  • 58. 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.
  • 59. $ swift build $ swift test
  • 60. SPM... AND XCODE swift package generate-xcodeproj
  • 63. CONTINUOUS INTEGRATION > catching probelms quickly, easily and early
  • 64. CONTINUOUS INTEGRATION > catching probelms quickly, easily and early > enhancing collaboration
  • 65. CONTINUOUS INTEGRATION > catching probelms quickly, easily and early > enhancing collaboration > broadening test coverage
  • 67. # .travis.yml language: objective-c osx_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
  • 68. # .travis.yml language: objective-c osx_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
  • 70. DANGER FILE2 # Sometimes it's a README fix, or something like that - which isn't relevant for # including in a project's CHANGELOG for example not_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 yet warn("PR is classed as Work in Progress") if github.pr_title.include? "[WIP]" # Warn when there is a big PR warn("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
  • 72. !
  • 73. 0 . 1 . 0
  • 74. 1 . 0 . 0
  • 75. RECAP
  • 76. RECAP > framework or not framework?
  • 77. RECAP > framework or not framework? > platform matters
  • 78. RECAP > framework or not framework? > platform matters > automate, automate, automate!
  • 79. RECAP > framework or not framework? > platform matters > automate, automate, automate! > open source