Slide 1

Slide 1 text

2 TOOLS AN iOS developer NEEDS TO KNOW Felizia Bernutz – 28.11.2018 – TH Nürnberg

Slide 2

Slide 2 text

learn about 2 tools we use at our daily work as iOS developers

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

SWIFTLINT & FASTLANE

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

SWIFTLINT

Slide 7

Slide 7 text

A tool to enforce Swift style and conventions — SwiftLint2 2 https://github.com/realm/SwiftLint

Slide 8

Slide 8 text

Why?

Slide 9

Slide 9 text

...because code style matters!

Slide 10

Slide 10 text

...because code style matters, right?

Slide 11

Slide 11 text

Watch the talk4 from JP Simard from Realm ON THE IDEAS BEHIND SWIFTLINT 4 https://academy.realm.io/posts/slug-jp-simard-swiftlint/

Slide 12

Slide 12 text

How?

Slide 13

Slide 13 text

#1

Slide 14

Slide 14 text

INSTALLATION ▸ With HomeBrew (global level) brew install swiftlint ▸ With CocoaPods (project level) pod 'SwiftLint' ▸ Install CocoaPods with sudo gem install cocoapods

Slide 15

Slide 15 text

#2

Slide 16

Slide 16 text

Add new RUN SCRIPT PHASE

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

#3

Slide 19

Slide 19 text

Define RULES1 1 https://github.com/realm/SwiftLint/blob/master/Rules.md

Slide 20

Slide 20 text

Type of Rules 1. Stylistic Rules

Slide 21

Slide 21 text

1. STYLISTIC RULES attributes // before @IBAction func showSomething() { ... }

Slide 22

Slide 22 text

1. STYLISTIC RULES attributes // before @IBAction func showSomething() { ... } // after @IBAction func showSomething() { ... }

Slide 23

Slide 23 text

1. STYLISTIC RULES vertical_parameter_alignment // before func buy(bananas: [Banana], withPlasticBag: Bool, isBio: Bool) { print("buy banana") }

Slide 24

Slide 24 text

1. STYLISTIC RULES vertical_parameter_alignment // after func buy(bananas: [Banana], withPlasticBag: Bool, isBio: Bool) { print("buy banana") }

Slide 25

Slide 25 text

Type of Rules 1. Stylistic Rules 2. Hygenic Rules

Slide 26

Slide 26 text

2. HYGENIC RULES ▸ File length ▸ Line length ▸ Body length

Slide 27

Slide 27 text

Type of Rules 1. Stylistic Rules 2. Hygenic Rules 3. Convention Rules

Slide 28

Slide 28 text

3. CONVENTION RULES legacy_cggeometry_functions // before let isInfinite = CGRectIsInfinite(rect)

Slide 29

Slide 29 text

3. CONVENTION RULES legacy_cggeometry_functions // before let isInfinite = CGRectIsInfinite(rect) // after let isInfinite = rect.isInfinite

Slide 30

Slide 30 text

Type of Rules 1. Stylistic Rules 2. Hygenic Rules 3. Convention Rules 4. Code Smells

Slide 31

Slide 31 text

4. CODE SMELLS ▸ force unwrap ▸ force cast ▸ force try ▸ number of function parameters

Slide 32

Slide 32 text

4. CODE SMELLS force_unwrapping // before navigationController!.pushViewController(loginVC, animated: true)

Slide 33

Slide 33 text

4. CODE SMELLS force_unwrapping // before navigationController!.pushViewController(loginVC, animated: true) // after guard let navController = navigationController else { return } navController.pushViewController(loginVC, animated: true)

Slide 34

Slide 34 text

Type of Rules 1. Stylistic Rules 2. Hygenic Rules 3. Convention Rules 4. Code Smells 5. Cyclomatic Complexity

Slide 35

Slide 35 text

5. CYCLOMATIC COMPLEXITY func complexFunction() { let i = 0 let array = [] if true { if i != 0 { if false {} } else { if !array.isEmpty && false { for element in array { guard i >= 0 && i < 42 else { return } if i >= 42 { switch i { case 42: break case 43: break case _ where i >= 44: print(i) default: break } } } } } } }

Slide 36

Slide 36 text

Type of Rules 1. Stylistic Rules 2. Hygenic Rules 3. Convention Rules 4. Code Smells 5. Cyclomatic Complexity

Slide 37

Slide 37 text

AND NOW Live Demo

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

https://twitter.com/KrauseFx/status/1055812829234782208

Slide 40

Slide 40 text

fastlane3 is a tool for iOS and Android developers to automate tedious tasks 3 https://github.com/fastlane/fastlane

Slide 41

Slide 41 text

No content

Slide 42

Slide 42 text

WHY FASTLANE?

Slide 43

Slide 43 text

WHY FASTLANE? ▸ saves time

Slide 44

Slide 44 text

WHY FASTLANE? ▸ saves time ▸ open source

Slide 45

Slide 45 text

WHY FASTLANE? ▸ saves time ▸ open source ▸ easy setup

Slide 46

Slide 46 text

WHY FASTLANE? ▸ saves time ▸ open source ▸ easy setup ▸ integrate with CI systems

Slide 47

Slide 47 text

CONTINOUS INTEGRATION

Slide 48

Slide 48 text

How?

Slide 49

Slide 49 text

#1

Slide 50

Slide 50 text

INSTALLATION ▸ Using RubyGems sudo gem install fastlane -NV ▸ Using Homebrew brew cask install fastlane

Slide 51

Slide 51 text

#2

Slide 52

Slide 52 text

SET UP Fastfile

Slide 53

Slide 53 text

desc 'Runs all tests' lane :test do run_tests( device: 'iPhone X', scheme: 'Testing' ) end

Slide 54

Slide 54 text

#3

Slide 55

Slide 55 text

And then... fastlane test

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

[22:22:32]: ▸ ✓ testSelectRowShouldSetCorrectSelectedSetting (0.001 seconds) [22:22:32]: ▸ Executed 32 tests, with 0 failures (0 unexpected) in 0.162 (0.182) seconds [22:22:33]: ▸ 2018-11-19 22:22:33.198 xcodebuild[53785:4181855] [MT] IDETestOperationsObserverDebug: 24.020 elapsed -- Testing started completed. [22:22:33]: ▸ 2018-11-19 22:22:33.198 xcodebuild[53785:4181855] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start [22:22:33]: ▸ 2018-11-19 22:22:33.198 xcodebuild[53785:4181855] [MT] IDETestOperationsObserverDebug: 24.020 sec, +24.020 sec -- end [22:22:33]: ▸ Test Succeeded +--------------------+----+ | Test Results | +--------------------+----+ | Number of tests | 32 | | Number of failures | 0 | +--------------------+----+ +------+---------------------+-------------+ | fastlane summary | +------+---------------------+-------------+ | Step | Action | Time (in s) | +------+---------------------+-------------+ | 1 | Verifying fastlane | 0 | | | version | | | 2 | number_of_commits | 0 | | 3 | run_tests | 62 | +------+---------------------+-------------+ [22:22:39]: fastlane.tools finished successfully ! ✔ ~/develop/_private/cineaste-ios [master|⚑ 11] 22:22 $

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

Without fastlane it would be xcodebuild \ -workspace Minions.xcworkspace \ -scheme "Testing" \ -sdk iphonesimulator \ -destination 'platform=iOS Simulator,name=iPhone X' \ test

Slide 60

Slide 60 text

AND NOW Live Demo

Slide 61

Slide 61 text

WHAT WE @ADORSYS USE FASTLANE FOR?

Slide 62

Slide 62 text

WHAT WE @ADORSYS USE FASTLANE FOR? ▸ run tests

Slide 63

Slide 63 text

WHAT WE @ADORSYS USE FASTLANE FOR? ▸ run tests ▸ build app

Slide 64

Slide 64 text

WHAT WE @ADORSYS USE FASTLANE FOR? ▸ run tests ▸ build app ▸ make screenshots

Slide 65

Slide 65 text

WHAT WE @ADORSYS USE FASTLANE FOR? ▸ run tests ▸ build app ▸ make screenshots ▸ upload app to Testflight, AppStore or adorsys AppCatalog

Slide 66

Slide 66 text

THANKS Questions?

Slide 67

Slide 67 text

Felizia Bernutz ▸ @fbernutz ▸ @felibe444 ▸ ! iOS dev @adorsys 28.11.2018 – TH Nürnberg