iOS dev!

Android to iOS

I’ve recently started doing some native iOS Swift/UIKit dev work.

Linting

Been enjoying using a linter like SwiftLint. The linter is applied every time xcode builds. In the terminal, you can navigate to the project folder and swiftlint autocorrect. This will apply all the lint rules from swiftlint.yml. Be sure to change your xCode settings, so that SwiftLint nags you less! xCode text editing whitespace setting You can also add swift linting as a build stage in xcode.

namespaces

Its kind of strange that Swift doesnt support namespacing, but local packages are a useful alternative.

Android

Coming from Android native development, I found the this article to be helpful. Basically: LinearLayout = UIStackView and Fragment = UIViewController (but iOS has more lifecycle events). Architecturally, this article was helpful with outlining the similarities. Basically, AppDelegate = MainActivity and UITableView = RecyclerView.

Dependency injection

I am a big fan of Koin for serviceLocation/DI on Android. Resolver looks promising as an alternative on iOS.

Cocoapods

If you use CocoaPods for your dependency management, you can brew install cocoapods to install cocoapods.Close your xcode project. Then, in your project directory, pod init and edit the resulting pod file according to the documentation. Finally, pod install.

AutoLayout

WTF Autolayout? can be helpful with debugging layout constraint errors. Tiny Constraints also looks like it will take some of the pains away.

Templating

Its very annoying that code does not do the importing automatically (when would I not use UIKit?), so you can adjust the default Swift template to provide the import. Just go to /Applications/Xcode.app/Contents/Developer/Library/Xcode/Templates/File\ Templates/Source/Swift\ File.xctemplate and edit it with Vscode or something (you will need sudo in order to save it).

xCode

Xcode quite frankly is miles behind Android Studio. Intellij have a paid for product which looks much better.

Comments