UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Tips for Android developers switching to Swift

Swift version: 5.6

Paul Hudson    @twostraws   

Here are my top ten tips to help you switch from coding Java on Android to coding Swift on iOS:

  1. Find a good tutorial and follow it. Obviously I suggest my own Hacking with Swift and Pro Swift books!
  2. Don't bother with iOS 8 and earlier; 80% of people are already on iOS 9, and by the time you're shipping apps that will be higher.
  3. You're used to debugging on devices because the Android Emulator is poor. The iOS Simulator is excellent, and you should use it. Be warned, though: the iOS Simulator runs at the full speed of your Mac, so you should always do performance testing on devices.
  4. If you're looking for LinearLayout, use UIStackView. If you're looking for Fragments, use UIViewController. If you're looking for Volley, use Alamofire. If you're looking for Java, you should head back to Android.
  5. Don't skimp on learning Auto Layout. It is hard, and it is a bit like black magic at first, but once you understand it your life becomes much easier.
  6. Forget about DPs, SPs, etc. iOS works in virtual points, and the system handles the rest.
  7. If you want to support the widest range of devices, you should learn about Size Classes. They let one app look and work great on everything from iPhone 4s through to iPad Pro, including going between Slide Over, Split View and full screen.
  8. You have a lot more memory to play with, and your code will execute substantially faster. Garbage collection does not happen, so you'll find far fewer cases where your code stutters before optimization.
  9. The Instruments tool that is built into Xcode is a dream come true if you're coming from Android Studio. Same applies to XCTest for unit testing and UI testing. Downside: iOS has nothing like the Application Exerciser Monkey.
  10. Most important of all, use an iPhone or iPad for a while so you start to get a feel for the platform's design principles. Google has a terrible habit of making their iOS apps look like Android apps, which is just confusing for users. iOS design is simple and clear, but it's extremely consistent. Except for Google. Sigh….

iOS is a really fun platform to code for, and Apple's devices have a huge amount of power available to you. Have fun!

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

Sponsor Hacking with Swift and reach the world's largest Swift community!

Available from iOS 9.0

Similar solutions…

About the Swift Knowledge Base

This is part of the Swift Knowledge Base, a free, searchable collection of solutions for common iOS questions.

BUY OUR BOOKS
Buy Pro Swift Buy Pro SwiftUI Buy Swift Design Patterns Buy Testing Swift Buy Hacking with iOS Buy Swift Coding Challenges Buy Swift on Sundays Volume One Buy Server-Side Swift Buy Advanced iOS Volume One Buy Advanced iOS Volume Two Buy Advanced iOS Volume Three Buy Hacking with watchOS Buy Hacking with tvOS Buy Hacking with macOS Buy Dive Into SpriteKit Buy Swift in Sixty Seconds Buy Objective-C for Swift Developers Buy Beyond Code

Was this page useful? Let us know!

Average rating: 3.8/5

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.