Things I wish I had known before starting iOS development — Part 2

If you have not read the first part of this post, please read it and then came back to the second part.

In the first part, I talked about the fundamental aspects of learning iOS development. The second part will be more focussed on the problems that you will face when you start developing your own apps for the iOS platform.

Debugging

Trust me you are going to face a lot of errors and exceptions when developing your own apps like the NSInvalidArgumentException, NSInternalInconsistencyException or the ones with the codes like 0xfaded322. You will run to Stack Overflow or Quora to find the answers to these errors but a lot of times you would have to figure the error yourself.

Xcode with features like breakpoints, view debugging and logging is a good tool for debugging but you will need some other powerful tools to easily debug your app.

1.Pony Debugger

This powerful open source tool by square is a remote debugging toolset that operates as a client library and gateway server combination using Chrome Developer Tools on a web browser to debug an application’s network traffic and data store. PonyDebugger acts as a powerful network debugger, allowing users the ability to see an application’s network requests in real time. Another cool feature of PonyDebugger is its ability to remotely debug an iOS application’s Core Data stack.

2.Cocoa Lumberjack

CocoaLumberjack is a fast & simple, yet powerful & flexible logging framework for Mac and iOS. If you are looking for a powerful logger with some great features like custom formatters, this might be the one for you.

3. Reveal App

Although view debugging has been introduced to iOS, the reveal app is much more powerful in debugging your views in detail. Though it is a paid solution, but it is worth it as some of the features like Auto Layout Inspection are just amazing.

4. OHHTTPStubs

OHHTTPStubs is a library designed to stub your network requests very easily. It can help you:

  • test your apps with fake network data (stubbed from file) and simulate slow networks, to check your application behavior in bad network conditions
  • write Unit Tests that use fake network data from your fixtures.

Data Storage

For most of the apps you develop, you may need to store some data locally for a variety of tasks. Data storage is a pretty complex topic with a lot of options available, each suited to particular use cases for your app. But I liked this rule of thumb to choose your data storage that was posted on Stack Overflow.

  • If the data fits in memory entirely and is relatively unstructured, use plist
  • If the data fits in memory entirely and has tree-like structure, use XML
  • If the data does not fit in memory and has a structure of a graph, and the app does not need extraordinary query capabilities, use Core Data
  • If the data does not fit in memory, has a complex structure, or the app benefits from powerful query capabilities provided by relational databases, use sqlite
  • If the data must be secret (e.g. a password), use keychain.

Some of the libraries that might help you with data storage are listed below.

FMDB

If you choose to use SQLite in your project, take advantage of this wrapper library as it will make your work pretty easy.

SSFKeychain

For storing sensitive data in your app, you must always go for keychain. This library will make the data storage in keychain very simple.

Magical Record

Core data can be pretty complex to manage. This library will make its management a breeze.

Networking

You will surely have to interact with some API’s to make your apps more interesting. Although iOS have some pretty support for networking like NSURLSession, NSURLConnection, NSJSONSerialization but I recommend the following libraries to use for networking.

AFNetworking

I think this is one of the best libraries ever written for iOS with some amazing features. Perhaps the most important feature of all, however, is the amazing community of developers who use and contribute to AFNetworking every day. AFNetworking powers some of the most popular and critically-acclaimed apps on the iPhone, iPad, and Mac.

Restkit

Restkit has an elegant, carefully designed set of APIs that make accessing and modeling RESTful resources feel almost magical. If you are using core data for storage and rest services for fetching, Restkit might be the right option for you as it seamlessly integrates with Core Data.

Alamofire

Don’t worry Swift lovers, I have a treat for you as well. Alamofire is an elegant networking library with some powerful features written specifically for Swift.

You can find a lot of other libraries here.

Managing Dependencies

I talked about dependency management in the previous post but this a very important topic so needs some discussion in detail. There are three important ways in which you can manage dependencies in your project.

CocoaPods

CocoaPods is the dependency manager for Swift and Objective-C Cocoa projects. It has almost ten thousand libraries and can help you scale your projects elegantly. It is the most effective way to manage dependencies similar to Ruby Gems in approach.

There is a hilarious youtube video by Google Developers explaining why you must use CocoaPods in your projects.

Github Submodules

You can also use git submodules to organize your dependencies as sub repos in your project. The advantage submodules have over Cocoapods is that submodules are sub-repos — not only does this mean that git and git GUIs implicitly recognize them and more and more support easily working with them, it also means that your dependencies stay connected the wonderful world their git repos, Cocoapods or not, reside in.

The problem with git submodules is this: your project doesn’t have the source for code you depend on. It only has a reference to the submodule’s repository. And most of the time you don’t even control that repository.

Carthage

Carthage is intended to be the simplest way to add frameworks to your Cocoa application. Carthage builds framework binaries using xcodebuild, but leaves the responsibility of integrating them up to the user. CocoaPods’ approach is easier to use, while Carthage’s is flexible and unintrusive.

Unfortunately, there is one big disadvantage about Carthage — Only support iOS 8 or later.

Testing

I know most of us seem to yawn when it comes to testing our apps. But testing is essential to ensure that your app will not break at unexpected times. If you are shipping an app, make sure to test it extensively to give your users the best experience.

There are plenty of testing frameworks that will make your work easier.

XCTest

Xcode includes XCTest, a unit testing framework, and support for running unit tests as part of your project’s build process. As XCTest is tightly integrated with XCode, it provides features like support for continuous integration and test coverage.

KIF

KIF, which stands for Keep It Functional, open sourced by Square is an iOS integration test framework. It allows for easy automation of iOS apps by leveraging the accessibility attributes that the OS makes available for those with visual disabilities.

Kiwi

Kiwi is a Behavior Driven Development library for iOS development. The goal is to provide a BDD library that is exquisitely simple to setup and use.

Quick

Quick is a behavior-driven development framework for Swift and Objective-C. Inspired by RSpec,Specta, and Ginkgo. Quick comes together with Nimble — a matcher framework for your tests.

I have tried to cover a lot of technical stuff in this post. Once you start developing iOS apps you will be able to appreciate the above topics and libraries. There is so much to write about iOS, so I could not include topics like marketing in this post. You will have to wait for one more post to know more about it.


Want to learn more about iOS and Swift enroll in this Swift Development Course available on discount for a limited period.

If you liked this post recommend it so that others can enjoy it as well.