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

Adventures of an Android Developer in iOS Land

Yun Cheng
November 06, 2018

Adventures of an Android Developer in iOS Land

What happens when a seasoned Android developer finds herself having to learn iOS from the beginning over the course of a few months? This survival guide will discuss lessons learned, differences in developing in the two platforms, and tips and resources to help you transition from Android to iOS development.

Yun Cheng

November 06, 2018
Tweet

More Decks by Yun Cheng

Other Decks in Programming

Transcript

  1. Getting XCode Don’t download from App Store: Prevent accidental upgrades

    that you’re not ready for Install any version side-by-side you want Download from https://developer.apple.com/downloads/. Rename additional downloads.
  2. A workspace is a collection of projects <- Open workspace

    Open project -> No pods Opening your project
  3. XCode vs Android Studio Can’t navigate from Activity to layout

    Refactoring No safe delete feature Autocomplete Find matching brace Double click on brace to find its match. Be prepared to search in path (cmd+shift+F) a lot
  4. Swift Optionals Know when to use • optional chaining •

    if let • guard let https://docs.swift.org/swift-book/LanguageGuide/TheBasic s.html#ID330 https://thatthinginswift.com/guard-statement-swift/
  5. Protocols (i.e. interfaces) UIKit classes use delegates (e.g. UITableViewDelegate, UIPickerViewDelegate,

    UICollectionViewDelegate, etc) class MyViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource { //Override methods for UIPickerViewDelegate } class MyActivity : AppCompatActivity(), NumberPicker.OnValueChangeListener { //Override methods for NumberPicker.OnValueChangeListener }
  6. Protocols (i.e. interfaces) cont. VC1 The delegate pattern in iOS

    is just using interfaces! VC1 : VC2Delegate { override func doTheThing(s: String) {} } v2Delegate.doTheThing(“MyValue”) Intent data = new Intent(); data.putExtra("myKey","myValue"); setResult(RESULT_OK,data); finish(); VC2
  7. Interface Builder 1) Hides information 2) Merge conflicts 3) Hard

    to review PRs Limit the scope of your storyboards!
  8. Use Swift Cleaner syntax Type inference No need to create

    header files http://goshdarnblocksyntax.com http://goshdarnclosuresyntax.com
  9. Swift Objective C interoperability Access Swift in ObjC: Add @objc

    annotation to Swift method or class Add #import "Runkeeper-Swift.h" to top of ObjC file https://medium.com/@JoyceMatos/mix-and-match-objecti ve-c-and-swift-c6bceb7f81f3
  10. Swift Objective C interoperability @objc static func launchAppOrStore(schemeString: String, appStore

    storeAppString: String) { ... } #import "Runkeeper-Swift.h" [[UrlOpener init] launchAppOrStoreWithSchemeString:(NSString * _Nonnull)kAsicsStudioScheme appStore:(NSString * _Nonnull)kAsicsStudioAppStoreUrl]; UrlOpener.swift : Invoke in ObjC:
  11. Swift Objective C interoperability @objc static func launchAppOrStore(schemeString: String, appStore

    storeAppString: String) { ... } #import "Runkeeper-Swift.h" [[UrlOpener init] launchAppOrStoreWithSchemeString:(NSString * _Nonnull)kAsicsStudioScheme appStore:(NSString * _Nonnull)kAsicsStudioAppStoreUrl]; cmd+click on Runkeeper-Swift.h import statement to see renamed methods UrlOpener.swift: Invoke in ObjC:
  12. Debugging Don’t use the variables view: -Not good with optional

    binding: if let nonOptionalThing = optionalThing {...} -Any thing derived from parent class doesn’t have those properties Use the lldb console to debug: po <object to inspect>
  13. Mocking Reflection is not allowed in Swift No Mockito equivalent

    in Swift class MockRunningPacksManager: RunningPacksManager {} https://github.com/Brightify/Cuckoo https://www.swiftbysundell.com/posts/mocking-in-swift
  14. Provisioning profiles Adds specific device IDs to a list of

    ones allowed to developer test your app TestFlight Don’t press fix it button for provisioning “Seek help ” - Jamie Hagemeister
  15. Regression testing Test on a fewer devices and fewer OS

    High adoption rate of new versions of the OS