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

Building 5 Calls for iOS

Building 5 Calls for iOS

A talk I gave in Barcelona. About 1/3 political, 1/3 technical, and 1/3 tactical.

Ben Scheirman

April 27, 2017
Tweet

More Decks by Ben Scheirman

Other Decks in Programming

Transcript

  1. 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
  2. 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 } }
  3. 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() }
  4. 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) }
  5. Getting dynamic fonts in code headline.font = UIFont.preferredFont( forTextStyle: UIFontTextStyleHeadline)

    subhead.font = UIFont.preferredFont( forTextStyle: UIFontTextStyleSubheadline) body.font = UIFont.preferredFont( forTextStyle: UIFontTextStyleBody)
  6. 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) }) }
  7. 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!
  8. R.swift let string = String(format: NSLocalizedString("welcome.withName", comment: ""), 
 locale:

    NSLocale.current, "Arthur Dent") let string = R.string.localizable.welcomeWithName("Arthur Dent") becomes…
  9. # Fastfile 
 desc "Runs all the tests" lane :test

    do scan(workspace: workspace, scheme: scheme) end
  10. 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
  11. 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
  12. 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
  13. 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
  14. 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
  15. 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
  16. 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
  17. 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"])
  18. !