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.
Things I wish I had known before starting iOS development — Part 1
My designer handed me a nifty looking onboarding flow to complete just days before the launching of our app. The flow…
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.
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.
PonyDebugger - Remote network and data debugging for your native iOS app using Chrome Developer Tools
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.
CocoaLumberjack - A fast & simple, yet powerful & flexible logging framework for Mac and iOS
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.
OHHTTPStubs - Stub your network requests easily! Test your apps with fake network data and custom response time…
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.
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.
If you choose to use SQLite in your project, take advantage of this wrapper library as it will make your work pretty easy.
sskeychain - Simple Objective-C wrapper for the keychain that works on Mac and iOS
For storing sensitive data in your app, you must always go for keychain. This library will make the data storage in keychain very simple.
Core data can be pretty complex to manage. This library will make its management a breeze.
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.
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 is a framework for consuming and modeling RESTful web resources on iOS and OS X
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.
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.
awesome-ios - A curated list of awesome iOS ecosystem, including Objective-C and Swift Projects
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 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.
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 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.
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.
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, 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 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.
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.