Getting started is simple:
- Download the boilerplate code
- Open the terminal and navigate to your project directory
- Run pod install. This is to install all the pods that are available for the boilerplate. If you don’t have cocoapods visit: http://cocoapods.org/
- Once the pods are installed, always use the Boilerplate.xcworkspace
- Now lets open the workspace.
Learning about the Boilerplate
The Project is organized into various folders serving different purposes:
- Source: All the source code that you are going to write will be in this directory and its sub directories. Source is again subdivided into Commons, Core, GUI and Model. You may virtually add more groups inside these directories, in Xcode, but there would not be a need to have physical subdirectories further inside these directories.
- Resources: All the project resources including fonts, images, localization info, plists, precompiled header, sounds and custom configuration files are under this directory.
- UnitTests: All the BDD tests are under this directory. We are using Kiwi to implement BDD tests. Kiwi is one of the best contextual testing frameworks. https://github.com/allending/Kiwi
- IntegrationTests: All the automation test classes reside in here. We are using KIF (Keep It Functional) framework. Again, one of the best native automation frameworks. https://github.com/kif-framework/KIF
- Frameworks: Any external frameworks outside of cocoapods need to go in here. For example, Crashlytics: www.crashlytics.com
- Docs: Well, that is where this doc is residing. But you can also use this for your project related documents (sequential diagrams etc.) that you want to be checked in.
- Pods: Don’t worry about this folder. It is created by cocoapods for all your pods. This is ignored by the git and need to run pod install to create this again.
There are three targets for the project:
- Boilerplate: This is the main target. You can rename this to your own project.
- UnitTests: This is the target used for Kiwi tests
- IntegrationTests: This is used for running automation tests. The KIF framework and related classes are compiled for this target.
Build Schemes and Run Info
There are three build schemes:
- Boilerplate: This runs the product of the main target.
- Boilerplate Distribution: This runs the product of the main target but needs to be codesigned with distribution profile. When you archive your product for distribution, you can use this target.
- Boilerplate Integration Tests: This runs the product of the IntegrationTests target. You can run this scheme in simulator and watch the application run by itself and test all the scenarios that you have created and show the results in the console.
To run the main target, Command+R. Ofcourse you know it.
To run the unit tests, Command+U.
To run the Integration tests, select the appropriate build scheme and Command+R. Sit back and watch it run by itself.
Boilerplate uses CocoaLumberjack logging framework; the most flexible one out there. It allows you to do fine grained logging, file logging, custom log formats and much more. Boilierplate has already customized CocoaLumberjack to the needs of your project. Refer to the following link to implement it further to your needs: https://github.com/robbiehanson/CocoaLumberjack/wiki/GettingStarted
Yes, you are about to call this silly. But this will save you a lot of time while debugging and reading your logs on your console. It colorizes the logs depending on the level of logging. Boilerplate already takes care of Xcode colors. However, you need to install the plugin for you Xcode. You can find it here: https://github.com/robbiehanson/XcodeColors
The download link for xcode colors: https://github.com/robbiehanson/XcodeColors/downloads
With the boilerplate, you can start connecting with your api endpoints with few lines of code. It uses AFNetworking. https://github.com/AFNetworking/AFNetworking
The APIClient (subclass of AFHttpClient) is a singleton instance that can serve as the wrapper for your api needs. The Boilerplate also provides a build scheme based api environment switcher which will make automatically change the environment to qa or prod when you change the scheme for debugging or distribution. Make sure you give appropriate values in the Constants.h file for the corresponding API endpoints.
Following are some of the custom controls/libraries that you could use (available as pods)
You can add these by adding the appropriate podspec to the podfile in the project directory and the version info. Run the pod install and you will see the libraries included. Make sure you update the custom configurations when you update the pods or add more pods. They are in resources folder.
The boilerplate also includes an Objective C Coding Conventions document that will help you with the latest and greatest programming practices. Make sure you read through that your codebase will be reveled like a gem!
Also, don’t forget to make code snippets of favorite thinks like commenting formats, pragma formats, class extensions and pretty function log statements. These will tremendously improve your speed of coding, making your code look even more beautiful and readable.
Credits: Boilerplate is a template for iOS development. All Frameworks and Libraries used/implemented/demonstrated are properties of corresponding authors and have been linked to.