iOS Boilerplate and Template

iOS Boilerplate and Template

Structure and foundation for building better iOS apps with coding standards, testing, common utilities and more.

Build iOS projects the right way with a professional boilerplate template

This boilerplate is a result of extensive experimentation and regression over months to create a great underlying codebase for any professional iOS project. It provides the structure and foundation to build better, more organized iOS apps, and get off the ground running. It does that by providing:

  • Proven, clear code structure for building small to large professional applications
  • Industry coding standards
  • Detailed logging and testing frameworks already included. Easier debugging and better quality control baked into your code base.
  • Integration of user tracking and analytics
  • Better asset organization
  • Equipped with API wrapper classes and framework to connect to your API endpoints with few lines of code
  • Localization support
  • And much more.

This boilerplate is targeted at beginning and intermediate iOS developers, who have not yet formalized their ideal app structure - but experts can benefit from it as well.

Coding standards

The boilerplate enforces and shows examples of the recommended coding standards for iOS development. Read more about the standards followed over on GitHub.

Hide

Getting Started

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

Organization

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.

Targets

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.

Logging

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

Xcode Colors

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

Networking

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.

Extras

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.

Hide

Example usage

Please see above

You need to log-in or create an account
  • Create an account
  • Log-in
Please use your real name.
Activation link will be sent to this address.
Minimum 8 characters
Enter your password again

Clicking this button confirms you read and agreed to the terms of use and privacy policy.

X

Save your watchlist

Fill your details below to receive project updates from your watch list - including new versions, price changes and discounts.

I agree to the terms of use and privacy policy.

3 licenses, starting from From » $99.99 14 day money-back guarantee View Licenses
or Get a quote

for customization or integration services

Post a comment

Or enter your name and Email
No comments have been posted yet.