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

2 Tools An iOS Developer Needs To Know

2 Tools An iOS Developer Needs To Know

97e98bcaf45715adc2fedabd3c5c1289?s=128

Felizia Bernutz

November 24, 2018
Tweet

Transcript

  1. 2 TOOLS AN iOS developer NEEDS TO KNOW Felizia Bernutz

    – 28.11.2018 – TH Nürnberg
  2. learn about 2 tools we use at our daily work

    as iOS developers
  3. None
  4. SWIFTLINT & FASTLANE

  5. None
  6. SWIFTLINT

  7. A tool to enforce Swift style and conventions — SwiftLint2

    2 https://github.com/realm/SwiftLint
  8. Why?

  9. ...because code style matters!

  10. ...because code style matters, right?

  11. Watch the talk4 from JP Simard from Realm ON THE

    IDEAS BEHIND SWIFTLINT 4 https://academy.realm.io/posts/slug-jp-simard-swiftlint/
  12. How?

  13. #1

  14. INSTALLATION ▸ With HomeBrew (global level) brew install swiftlint ▸

    With CocoaPods (project level) pod 'SwiftLint' ▸ Install CocoaPods with sudo gem install cocoapods
  15. #2

  16. Add new RUN SCRIPT PHASE

  17. None
  18. #3

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

  20. Type of Rules 1. Stylistic Rules

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

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

    ... } // after @IBAction func showSomething() { ... }
  23. 1. STYLISTIC RULES vertical_parameter_alignment // before func buy(bananas: [Banana], withPlasticBag:

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

    Bool, isBio: Bool) { print("buy banana") }
  25. Type of Rules 1. Stylistic Rules 2. Hygenic Rules

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

    Body length
  27. Type of Rules 1. Stylistic Rules 2. Hygenic Rules 3.

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

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

    // after let isInfinite = rect.isInfinite
  30. Type of Rules 1. Stylistic Rules 2. Hygenic Rules 3.

    Convention Rules 4. Code Smells
  31. 4. CODE SMELLS ▸ force unwrap ▸ force cast ▸

    force try ▸ number of function parameters
  32. 4. CODE SMELLS force_unwrapping // before navigationController!.pushViewController(loginVC, animated: true)

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

    after guard let navController = navigationController else { return } navController.pushViewController(loginVC, animated: true)
  34. Type of Rules 1. Stylistic Rules 2. Hygenic Rules 3.

    Convention Rules 4. Code Smells 5. Cyclomatic Complexity
  35. 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 } } } } } } }
  36. Type of Rules 1. Stylistic Rules 2. Hygenic Rules 3.

    Convention Rules 4. Code Smells 5. Cyclomatic Complexity
  37. AND NOW Live Demo

  38. None
  39. https://twitter.com/KrauseFx/status/1055812829234782208

  40. fastlane3 is a tool for iOS and Android developers to

    automate tedious tasks 3 https://github.com/fastlane/fastlane
  41. None
  42. WHY FASTLANE?

  43. WHY FASTLANE? ▸ saves time

  44. WHY FASTLANE? ▸ saves time ▸ open source

  45. WHY FASTLANE? ▸ saves time ▸ open source ▸ easy

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

    setup ▸ integrate with CI systems
  47. CONTINOUS INTEGRATION

  48. How?

  49. #1

  50. INSTALLATION ▸ Using RubyGems sudo gem install fastlane -NV ▸

    Using Homebrew brew cask install fastlane
  51. #2

  52. SET UP Fastfile

  53. desc 'Runs all tests' lane :test do run_tests( device: 'iPhone

    X', scheme: 'Testing' ) end
  54. #3

  55. And then... fastlane test

  56. None
  57. [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 $
  58. None
  59. Without fastlane it would be xcodebuild \ -workspace Minions.xcworkspace \

    -scheme "Testing" \ -sdk iphonesimulator \ -destination 'platform=iOS Simulator,name=iPhone X' \ test
  60. AND NOW Live Demo

  61. WHAT WE @ADORSYS USE FASTLANE FOR?

  62. WHAT WE @ADORSYS USE FASTLANE FOR? ▸ run tests

  63. WHAT WE @ADORSYS USE FASTLANE FOR? ▸ run tests ▸

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

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

    build app ▸ make screenshots ▸ upload app to Testflight, AppStore or adorsys AppCatalog
  66. THANKS Questions?

  67. Felizia Bernutz ▸ @fbernutz ▸ @felibe444 ▸ ! iOS dev

    @adorsys 28.11.2018 – TH Nürnberg