Slide 1

Slide 1 text

Building

Slide 2

Slide 2 text

Ben Scheirman benscheirman.com @subdigital

Slide 3

Slide 3 text

ficklebits.com

Slide 4

Slide 4 text

260+ screencasts on iOS development nsscreencast.com

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

What do we do?

Slide 9

Slide 9 text

No content

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

What do we do?

Slide 13

Slide 13 text

What can we do?

Slide 14

Slide 14 text

What can I do?

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

United States Congress House of Representatives Senate 435 Members 100 Members

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

No content

Slide 21

Slide 21 text

5calls.org

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

Launch ASAP

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

Wanted it to be a GOOD iOS app

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

github.com/5calls/ios

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

Let people help you!

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

Built on NSOperation Storyboards UITableView CocoaPods Vibrancy / Blur Dynamic Type Custom UIViewController Containment Local Push Notifications Fastlane Pantry Swift 3 Universal app
 (split view) Fabric / Crashlytics R.swift Buddybuild

Slide 34

Slide 34 text

NSOperations class BaseOperation : Operation { override var isAsynchronous: Bool { return true } 
 private var _executing = false { willSet { willChangeValue(forKey: "isExecuting") } didSet { didChangeValue(forKey: "isExecuting") } } override var isExecuting: Bool { return _executing } private var _finished = false { willSet { willChangeValue(forKey: "isFinished") } didSet { didChangeValue(forKey: "isFinished") } } override var isFinished: Bool { return _finished } class BaseOperation : Operation { func execute() { fatalError("You must override this") } func finish() { _executing = false _finished = true } }

Slide 35

Slide 35 text

NSOperations class FetchIssuesOperation : BaseOperation { let location: UserLocation? init(location: UserLocation?) { self.location = location }
 
 ... }

Slide 36

Slide 36 text

NSOperations override func execute() { let task = session.dataTask(with: url) { 
 (data, response, error) in if let e = error { print("Error fetching issues: \ (e.localizedDescription)”) } else { self.handleResponse(data: data, response: response) } self.finish() } task.resume() }

Slide 37

Slide 37 text

NSOperations self.issuesList = IssuesList(dictionary: json)

Slide 38

Slide 38 text

NSOperations func fetchIssues(completion: @escaping (IssuesLoadResult) -> Void) { let operation = FetchIssuesOperation(location: userLocation) operation.completionBlock = { [weak self, weak operation] in if let issuesList = operation?.issuesList { self?.issuesList = issuesList DispatchQueue.main.async { completion(.success) } } else {
 // …
 }
 
 } OperationQueue.main.addOperation(operation) }

Slide 39

Slide 39 text

NSOperations FetchIssuesOperation FetchStatsOperation ReportOutcomeOperation

Slide 40

Slide 40 text

NSOperations Composable Dependencies Cancellable Control Concurrency Quality of Service

Slide 41

Slide 41 text

NSOperations https://developer.apple.com/videos/play/wwdc2015/226/ WWDC Session 226 - Advanced NSOperations http://nsscreencast.com/ NSScreencast Episodes 175-177, 180

Slide 42

Slide 42 text

Dynamic Type Dynamic Type Dynamic Type

Slide 43

Slide 43 text

Using a custom font made this more difficult

Slide 44

Slide 44 text

No content

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

Getting Dynamic Type to work with UITableViewCells Define height with constraints

Slide 47

Slide 47 text

Getting Dynamic Type to work with UITableViewCells

Slide 48

Slide 48 text

Respond to Dynamic Type Changes UIContentSizeCategoryDidChangeNotification adjustsFontsForContentSizeCategory iOS 10.0

Slide 49

Slide 49 text

No content

Slide 50

Slide 50 text

Getting dynamic fonts in code headline.font = UIFont.preferredFont( forTextStyle: UIFontTextStyleHeadline) subhead.font = UIFont.preferredFont( forTextStyle: UIFontTextStyleSubheadline) body.font = UIFont.preferredFont( forTextStyle: UIFontTextStyleBody)

Slide 51

Slide 51 text

https://github.com/nickoneill/Pantry if let available: Bool = Pantry.unpack("promptAvailable") { completion(available: available) } else { anExpensiveOperationToDetermineAvailability({ (available) -> () in Pantry.pack(available, key: "promptAvailable", expires: .Seconds(60 * 10)) completion(available: available) }) }

Slide 52

Slide 52 text

var autopersist: String? { set { if let newValue = newValue { Pantry.pack(newValue, key: "autopersist") } } get { return Pantry.unpack("autopersist") } } ...later... autopersist = "Hello!" // restart app, reboot phone, etc print(autopersist) // Hello!

Slide 53

Slide 53 text

SIMPLE MODEL OBJECT…

Slide 54

Slide 54 text

CONFORM TO STORABLE

Slide 55

Slide 55 text

USAGE IS REALLY SIMPLE:

Slide 56

Slide 56 text

CAREFUL YOU DON’T STORE USER DATA IN CACHES

Slide 57

Slide 57 text

R.swift

Slide 58

Slide 58 text

R.swift let icon = UIImage(named: "settings-icon") let icon = R.image.settingsIcon() becomes…

Slide 59

Slide 59 text

R.swift let viewController = CustomViewController(nibName: "CustomView", bundle: nil) let viewController = CustomViewController(nib: R.nib.customView) becomes…

Slide 60

Slide 60 text

R.swift let string = String(format: NSLocalizedString("welcome.withName", comment: ""), 
 locale: NSLocale.current, "Arthur Dent") let string = R.string.localizable.welcomeWithName("Arthur Dent") becomes…

Slide 61

Slide 61 text

R.swift

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

# Fastfile 
 desc "Runs all the tests" lane :test do scan(workspace: workspace, scheme: scheme) end

Slide 65

Slide 65 text

$ fastlane test

Slide 66

Slide 66 text

desc "Increments build number" lane :increment_build do increment_build_number(xcodeproj: xcodeproj) end

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

desc "Submit a new Beta Build to Apple TestFlight" lane :beta do ensure_git_status_clean increment_build commit_version_bump badge(shield: "Version-#{app_version}-red", shield_no_resize: true) gym(workspace: workspace, scheme: scheme) changelog = prompt_for_release_notes pilot(changelog: changelog) git_commit(path: 'fastlane/changelog.txt', message: 'Updated changelog.txt') reset_git_repo(files: app_icon_files) add_git_tag push_git_tags end

Slide 69

Slide 69 text

desc "Submit a new Beta Build to Apple TestFlight" lane :beta do ensure_git_status_clean increment_build commit_version_bump badge(shield: "Version-#{app_version}-red", shield_no_resize: true) gym(workspace: workspace, scheme: scheme) changelog = prompt_for_release_notes pilot(changelog: changelog) git_commit(path: 'fastlane/changelog.txt', message: 'Updated changelog.txt') reset_git_repo(files: app_icon_files) add_git_tag push_git_tags end

Slide 70

Slide 70 text

desc "Submit a new Beta Build to Apple TestFlight" lane :beta do ensure_git_status_clean increment_build commit_version_bump badge(shield: "Version-#{app_version}-red", shield_no_resize: true) gym(workspace: workspace, scheme: scheme) changelog = prompt_for_release_notes pilot(changelog: changelog) git_commit(path: 'fastlane/changelog.txt', message: 'Updated changelog.txt') reset_git_repo(files: app_icon_files) add_git_tag push_git_tags end

Slide 71

Slide 71 text

desc "Submit a new Beta Build to Apple TestFlight" lane :beta do ensure_git_status_clean increment_build commit_version_bump badge(shield: "Version-#{app_version}-red", shield_no_resize: true) gym(workspace: workspace, scheme: scheme) changelog = prompt_for_release_notes pilot(changelog: changelog) git_commit(path: 'fastlane/changelog.txt', message: 'Updated changelog.txt') reset_git_repo(files: app_icon_files) add_git_tag push_git_tags end

Slide 72

Slide 72 text

desc "Submit a new Beta Build to Apple TestFlight" lane :beta do ensure_git_status_clean increment_build commit_version_bump badge(shield: "Version-#{app_version}-red", shield_no_resize: true) gym(workspace: workspace, scheme: scheme) changelog = prompt_for_release_notes pilot(changelog: changelog) git_commit(path: 'fastlane/changelog.txt', message: 'Updated changelog.txt') reset_git_repo(files: app_icon_files) add_git_tag push_git_tags end

Slide 73

Slide 73 text

def prompt_for_release_notes `open changelog.txt -W` File.read('changelog.txt') end

Slide 74

Slide 74 text

desc "Submit a new Beta Build to Apple TestFlight" lane :beta do ensure_git_status_clean increment_build commit_version_bump badge(shield: "Version-#{app_version}-red", shield_no_resize: true) gym(workspace: workspace, scheme: scheme) changelog = prompt_for_release_notes pilot(changelog: changelog) git_commit(path: 'fastlane/changelog.txt', message: 'Updated changelog.txt') reset_git_repo(files: app_icon_files) add_git_tag push_git_tags end

Slide 75

Slide 75 text

desc "Submit a new Beta Build to Apple TestFlight" lane :beta do ensure_git_status_clean increment_build commit_version_bump badge(shield: "Version-#{app_version}-red", shield_no_resize: true) gym(workspace: workspace, scheme: scheme) changelog = prompt_for_release_notes pilot(changelog: changelog) git_commit(path: 'fastlane/changelog.txt', message: 'Updated changelog.txt') reset_git_repo(files: app_icon_files) add_git_tag push_git_tags end

Slide 76

Slide 76 text

Automatic Screenshots # Snapfile devices([
 "iPhone 7"
 "iPhone 7 Plus",
 "iPhone SE",
 "iPad Pro (12.9 inch)"
 ]) languages(["en-US"])
 
 workspace "./FiveCalls/FiveCalls.xcworkspace"
 scheme "FiveCallsUITests" output_directory "./screenshots"
 clear_previous_screenshots true
 launch_arguments(["-hasShownWelcomeScreen false"])

Slide 77

Slide 77 text

Automatic Screenshots

Slide 78

Slide 78 text

Deterministic Data? How do we ALWAYS choose the same item, despite the server changing?

Slide 79

Slide 79 text

Stubs! {
 “issues”: [
 … ] 
 } issues.json INTERNET GET /issues UI TESTING? YES NO

Slide 80

Slide 80 text

No content

Slide 81

Slide 81 text

No content

Slide 82

Slide 82 text

SeededURLSession SeededDataTask dataTask(with:completion:)

Slide 83

Slide 83 text

No content

Slide 84

Slide 84 text

No content

Slide 85

Slide 85 text

HOST APP TESTS ENV

Slide 86

Slide 86 text

TESTS

Slide 87

Slide 87 text

No content

Slide 88

Slide 88 text

No content

Slide 89

Slide 89 text

No content

Slide 90

Slide 90 text

The Stats

Slide 91

Slide 91 text

Week 1 6,300 downloads

Slide 92

Slide 92 text

No content

Slide 93

Slide 93 text

No content

Slide 94

Slide 94 text

Month 1 76,916 downloads

Slide 95

Slide 95 text

No content

Slide 96

Slide 96 text

All Time (4/21/2017) 105,000 downloads

Slide 97

Slide 97 text

44.2k Monthly Active Users 2.4k Daily Active Users

Slide 98

Slide 98 text

No content

Slide 99

Slide 99 text

Over 1 million calls to congress

Slide 100

Slide 100 text

Final Thoughts

Slide 101

Slide 101 text

!

Slide 102

Slide 102 text

Track Useful Analytics *but don’t be scummy

Slide 103

Slide 103 text

No content

Slide 104

Slide 104 text

No content

Slide 105

Slide 105 text

No content

Slide 106

Slide 106 text

REDMAP

Slide 107

Slide 107 text

No content

Slide 108

Slide 108 text

Software Development is an incredibly valuable skill.

Slide 109

Slide 109 text

Software Development is an incredibly valuable skill. Use your powers for good, not evil.

Slide 110

Slide 110 text

Ben Scheirman benscheirman.com @subdigital nsscreencast.com ¡Gracias!