iOS Coding Guidelines

I am not saying the following guidelines are perfect but I like to use them to bring consistency to my projects. I thought I would share in case someone else needs a place to get started.

Naming Conventions

  • Use Pascal Case for files, folders and classes
    • start with a capital letter
    • i.e. Controllers, MyClass, BlueprintListTableViewController, etc.
  • Use Camelcase for methods, functions, properties & variables
    • start with a lowercase letter
    • i.e createFirstName:, userPassword, etc.
  • Avoid using acronyms and abbreviations
    • do not create things like: usrPswdLbl
    • just because Swift is a less verbose language than ObjeciveC does not mean I choose brevity over clarity when naming things

Coding Conventions

At the creation of this document Swift 2.0 is still in beta and evolving.  There are no specific coding conventions that are considered the definitive guide.  Until such a time we should follow the One True Brace Style (1TBS) and The Swift Programming Language book by Apple.

For Objective C guidelines the Apple Coding Guidelines for Cocoa should be followed.  

iOS App xCode Project and Folder Structure


Here is an example of the folder / group layout to use for projects.  See the details below for more on the purpose of each.


Application – specific app related stuff like AppDelegate, main.m, .pch etc

Controllers – view controller and the components that make them

  • Put .swift, .xib, .h, and .m together in the same folders
  • One (physical) folder for each view controller
  • If there are too many, group them into a subfolder
  • Group them by tab (TabBar) or by functions

Libraries – specific application classes like helpers, base classes, services, etc

Models – application domain models and entities, Core Data model too

Resources – assets like images, fonts, sounds, videos, etc.

  • .xcassets files should be used for all local images
  • One folder for each type of asset (new images.xcassets are actually examples of this and can live at the top level of the Resources folder)
    • images, fonts, sounds, videos, strings, plist
  • If the app will support multiple themes, create a hierarchy
    • themes > themes name > images, fonts, etc.
  • Name image based on state
    • ie: button_blue_norma, button_blue_highlighted

Vendors – third party libraries and frameworks

  • Vendor SDKs and Libraries that are not supported by cocoapods
  • These don’t belong in the Libraries Folder (vendor trumps library)

Crossfit Total Just added to Appstore

crosfitTotal120x120 Quickly calculate your crossfit total. Just follow the rules of lifting a total where you are allowed 3 attempts:


After each lift enter your weight into the calculator and when you finish, simply hit the calculate button and find out your CF Total.


Sunset Utility Open Source Code

A little while ago I wrote a simple utility that can be added to your iOS project that allows you to notify users that you are shutting down this app. It is available on github and free to use.

You can refer users to a different app if you like. You can also stage the rollout with a cancel button that allows users to keep using the app. Then you can set a switch to only allow download of the new app.

MMWormhole is great.

I have not posted anything in a while, but wanted to just link out to a really cool open source tool for working with Watchkit.  It is called MMWormhole and it let’s you send data from your watchkit extension over to the parent app and back again.  The really cool thing is it is setup for notifications.  Your app is listening for the data and can act upon it when the data is received.  This is really helpful with iOS7.  Great work Mutual Mobile.

WatchKit – Day One

WatchKit was made avaliable today by Apple.  I have had just a quick read but this is a key to categorizing the different types of interactions.

  • Your Watch app contains your app’s full user interface. The user launches your app from the home screen and uses the app to view or manipulate data.

  • glance is an optional read-only interface that you use to display the most timely and relevant information from your app. Not all apps need a glance, but having one gives the user a convenient way to access your app’s data.

  • Custom notification interfaces let you alter the default interface displayed for recently received local and remote notifications and add custom graphics, content, and formatting. Custom notification interfaces are optional.

We know that Watch Apps require an iPhone to run third party apps.  That is an interesting wrinkle.  What does that mean for fitness apps?  At least non-Apple fitness apps.  I hope to know more in the coming days.  I will put together some kind of proof of concept app to learn a bit more.

Also, we know that based on a recent press release from Apple that third party developers will have to wait until later in 2015 until they can ship full watch apps.  This means our apps are going to fall into the category of either glances or notifications.  It is not exactly what I was hoping for, but interesting none the less.

I will post something more after I get a little more time with WatchKit.



Note to self: In-App Purchases

Every time I go to add an in-app purchase to one of my apps, I forget the pattern that was set up for my Product Id.  I like to use the reverse domain and the product name tagged on the end like Apple suggests.


A product identifier is a string used to uniquely identify every product you wish to sell from your application. The App Store uses it to retrieve information about a product. It is a string identifier that can only contain alphanumeric (A-Z,a-z,0-9), underscore (_), and period (.) characters. You can use any sequence of these characters for your identifier. However, we recommend that you use the reverse domain name style (for example, com.companyname.application.productid) when creating your identifier


Hopefully by writing this post it will help me remember that I have this set up this way.  Burned a couple of hours trying to figure it out and it was right there all along.

Here is the link to the Apple Documentation.

Xcode 6 fixed archive functionality

I just noticed that in Xcode 6, you no longer have to disconnect your device to build an archive.  In the past I always forget to disconnect and it would drive me crazy.  I see that now, it does not matter if the device is connected or not.  Very nice.