Manbolo Blog

Manbolo Team Blog, creators of MeonArchives

Use Python Effectively on OS X

This post is an unorganised collection of notes about how I use Python effectively on OS X. Disclaimer: I don’t pretend to be a Python expert, by a far mesure, so there could be some Pythonic horrors in this article; if you think so, just drop us a mail, and we’ll update this article.

TL&DR: don’t use the pre-installed OS X Python. Use Python with Homebrew. Never ever sudo pip. Use virtualenv / virtualenvwrapper. PyCharm worth the price. Python rocks.

  1. OS X default Python installation
  2. Installing brew
  3. Installing Python 2.7 with brew
  4. Installing third-party libraries
  5. Shell scripts with Python
  6. Must-have packages
  7. Python 3
  8. IDEs on OS X
  9. Various tools

1. OS X default Python installation

A quick word about the default Python installation. Python comes pre-installed on OS X. If you open a terminal, and simply ask for the location of the python binary, you will see:

$ which python

Launching the interpreter in a terminal window:

$ python
Python 2.7.5 (default, Mar  9 2014, 22:15:05)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

So Python 2.7.5 is the default python interpreter. If you need to, Python 2.6.8 and Python 2.5.6 are also available on a vanilla OS X.

Simply use python2.6 for Python 2.6.8:

$ python2.6
Python 2.6.8 (unknown, Mar  9 2014, 22:16:00)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

And python2.5 for Python 2.5.6:

$ python2.5
Python 2.5.6 (r256:Unversioned directory, Mar  9 2014, 22:15:03)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

While it can be convenient to have a pre-installed Python, my rookie advise is to not use it: Apple doesn’t always do a good job on keeping the Python runtime environment up to date, plus it can be cumbersome to play with permissions just to install third-party Python librairies, and finally, Apple has a tendency to wipe-out your site-packages with every major OS upgrade.

So I simply recommend to install Python aside the default one, with Homebrew. You’ll never have to use sudo or have permissions problem; if you have any issues, you can drop /usr/local and start from fresh without having messed up your OS X system. Let’s do it now!

2. Installing brew

There are many package installers on OS X but I find Homebrew very pleasant, simple and convenient. Homebrew, originally started by Max Howell, simplify the installation of open source tools (like ImageMagick, wget, ag etc..) that are not by default on OS X.

What I really like with Homebrew is that everything is installed in a directory that is not conflicting with the system directories. By default, it’s on /usr/local but you can change to whatever you like.

Installing Homebrew is very simple: open a Terminal window and type

ruby -e "$(curl -fsSL"

3. Installing Python 2.7 with brew

Now that our Homebrew installation is done, we can install Python. We’re going to start by installing Python 2.7:

$ brew install python

Now, we need to tell the system to use our freshly new Python interpreter instead of the default one.

$ which python

The default Python interpreter is under /usr/bin, and the Homebrew’s one is under /usr/local/bin so we’re going to edit /etc/paths so the /usr/local/bin binaries will be prioritised over /usr/bin.

$ sudo vi /etc/paths

If you open /etc/paths, you should see this:


Move /usr/local/bin at the beginning of the file so Homebrew binaries take on system binaries;


Finally, check everything is ok: typing python should launch the Homebrew version

$ source /etc/paths
$ which python

$ python
Python 2.7.8 (default, Jul  2 2014, 10:14:46)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

pip has been also installed alongside our brewed Python; pip will allow us to easily install and manage Python packages.

$ which pip

With this setup (brewed python), you’ll NEVER have to use sudo to install any Python relative stuff. If you end up doing this, something is broken in your brewed Python installation.

4. Installing third-party libraries

4.1. Essential

There are two kind of third-party libraries: those you want to be installed anytime with your default Python, and those you like to play with, or use only for your toys projects. You don’t want to mess your default Python, so I recommend to install only the essential libraries in your default Python (which is /usr/bin/local/python if you’ve followed my previous advices).

Those essentials libraries depends on your needs, and will be different from one person to another. In Must-have packages, I’ve listed some open source packages that I found convenient to be always present in my system.

You’ll be able to install the other libraries in a virtual Python environment, that could be used and / or trash anytime, without messing up your brewed installation.

Let’s take the example of a library that I want to always be available in my Python interpreter: Requests. To install it, I simply pip install request in a terminal window. This way, each time I use my default Python, I can do HTTP requests really easily.

$ pip install requests

$ python
Python 2.7.8 (default, Jul  2 2014, 10:14:46)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> requests.__path__

4.2. virtualenv

Now, you could theoretically install all the third parties libraries you need in your default Python. But, imagine you have a script that needs version 1 of LibFoo, but another script requires version 2. How can you use both these scripts? If you install everything into /usr/local/lib/python2.7/site-packages/, it’s easy to end up in a situation where you unintentionally upgrade something that shouldn’t be upgraded.

Or more generally, what if you want to install an application and leave it be? If an application works, any change in its libraries or the versions of those libraries can break the application.

To address this, we’re going to use virtualenv. virtualenv allows you to create an optimised, independent and sandboxed copy of your default Python. You’ll be able to install packages in this virtual Python environment, and only in this environnement. You will be able to use this Python interpreter (or activate it), play with it, and comes back (deactivate) to the default environnement. You will be able to have multiple venvs (shortcut for virtual Python environment), each one being completely independent of the others; you will be able to switch between environment, execute periodic scripts in a given environment etc…

To install virtualenv, just use your default pip:

pip install virtualenv

Example: you want to play with latest version of Django. So the first step is to create a venv for the latest version of Django. You can create a venv anywhere on your disk, and you do not need to be root to do this, you just need write permissions. For example, you can install a new venv in your Documents directory:

$ cd ~/Documents
$ virtualenv -p /usr/local/bin/python2.7 venv-django

This command has created a sandboxed version of your Python environment under the folder venv-django. By default, this copy comes clean, without the third-party packages that are installed in your default Python. This allows you to start from a clean, new state. You can open the folder ~/Documents/venv-django and you will see a sandboxed Python environment:

$ cd ~/Documents/venv-django
$ ls -l
total 0
drwxr-xr-x  19 jc  staff  646 Sep 27 11:43 bin
drwxr-xr-x   3 jc  staff  102 Sep 27 11:43 include
drwxr-xr-x   3 jc  staff  102 Sep 27 11:43 lib
$ cd bin
$ ls -l
total 160
-rw-r--r--  1 jc  staff   2203 Sep 27 11:43 activate
-rw-r--r--  1 jc  staff   1259 Sep 27 11:43 activate.csh
-rw-r--r--  1 jc  staff   2472 Sep 27 11:43
-rw-r--r--  1 jc  staff   1129 Sep 27 11:43
-rwxr-xr-x  1 jc  staff    253 Sep 27 11:43 easy_install
-rwxr-xr-x  1 jc  staff    253 Sep 27 11:43 easy_install-2.7
-rwxr-xr-x  1 jc  staff    150 Sep 27 11:43 get_env_details
-rwxr-xr-x  1 jc  staff    225 Sep 27 11:43 pip
-rwxr-xr-x  1 jc  staff    225 Sep 27 11:43 pip2
-rwxr-xr-x  1 jc  staff    225 Sep 27 11:43 pip2.7
-rw-r--r--  1 jc  staff     72 Sep 27 11:43 postactivate
-rw-r--r--  1 jc  staff     74 Sep 27 11:43 postdeactivate
-rwxr-xr-x  1 jc  staff     69 Sep 27 11:43 preactivate
-rw-r--r--  1 jc  staff     75 Sep 27 11:43 predeactivate
lrwxr-xr-x  1 jc  staff      9 Sep 27 11:43 python -> python2.7
lrwxr-xr-x  1 jc  staff      9 Sep 27 11:43 python2 -> python2.7
-rwxr-xr-x  1 jc  staff  12744 Sep 27 11:43 python2.7

A new python interpreter is here and ready to serve! But currently the Python interpreter is still the default one.

$ which python

To switch to the interpreter of the venv, you need to activate it. source the bin/activate script that have been created in the venv folder:

$ source ~/Documents/venv-django/bin/activate

(venv-django)$ which python 

(venv-django)$ which pip

You can see that your shell prompt is now prefixed with the name of the current activated environment (very convenient). You can test that no third-party packages have been installed and that your virtual env is clean:

(venv-django)$ python
Python 2.7.8 (default, Jul  2 2014, 10:14:46)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named requests

You can use this new Python environment without fearing to break anything, or to bloat you default Python. activate simply add the virtual env Python binaries to your PATH, in front of system defined binaries. Each time we’ll use pip or python, we’ll use the ones that are in this sandbox.

Now, we can safely install Django in your new environment:

(venv-django)$ pip install django
(venv-django)$ python
Python 2.7.8 (default, Jul  2 2014, 10:14:46)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django

To leave the current virtualenv, and go back to the default Python, just type deactivate in any path.

$(venv-django) deactivate   

Back to the default Python, Django is not installed and everything is clear.

You don’t need to do the activate/deactivate dance each time you want to use a particular venv. Let’s say you want to execute a cron task is using a virtual env defined at ~/Documents/venvs/myvenv. You can use the venv python interpreter to launch (without calling activate), and everything will just works, your script will be able to import any module defined in your venv:

$ ~/Documents/venvs/myvenv/bin/python

4.3. virtualenvwrapper

Working with multiple virtualenv can become really teddy and cumbersome: you have to switch and remember where is located the venv you want to use. This is where virtualenvwrapper comes to place: virtualenvwrapper is a set of extensions to virtualenv tool. You can easily list, create and delete virtual environments; all of your virtual environments are organized in one place.

Installing virtualenv is really simple, with your main Python:

pip install virtualenvwrapper

Next, you have to add source /usr/local/bin/ to your shell startup file (on OS X, you can put this at the end of ~/.bash_profile).

Then, everything is set up and you can create a new venv:

$ mkvirtualenv env1
New python executable in env1/bin/python2.7
Also creating executable in env1/bin/python
Installing setuptools, pip…done.
(env1)~ $

By default, all your virtual environments will be created under ~/.virtualenvs/ but you can change it.

List all environnement:

$ workon

Switch on environnement env1:

$ workon env1

5. Shell scripts with Python

If you write shell scripts in Python, you can launch your script by simply call:

$ python

This will execute your script, with the current python interpreter. If your script need a particular virtual environnement to run, you can run it in this virtual environment without having to activate it before. Simply hard code the python interpreter binary that ways:

$ /Users/jc/.virtualenvs/env1/bin/python

This will execute the script in the virtual environnement defined at /Users/jc/.virtualenvs/env1. All the packages that you have installed in this virtual environnement will be callable in the script.

If you want to call directly your script without typing python, add the proper permission on your script

$ chmod u+x

And add the following shebang at the beginning of your script:

#!/usr/bin/env python

You can also point to a particular python interpreter if you want:


Which is considerably less portable. #!/usr/bin/env python will use the current python interpreter of your shell session (which can be a virtualenv ones).

Finally, it’s a best practice to declare the encoding of your script file. On OS X, use UTF-8.

For example, the following script:

#!/usr/bin/env python

if __name__ == ’__main__’:
    print("Hello こんにちは!")

will produced this error when executed:

File "./", line 5
SyntaxError: Non-ASCII character ’\xe3’ in file ./ on line 5, but no encoding declared; see for details

With the proper encoding hint, everything works as it should be (you can even use emojis if you want!):

#!/usr/bin/env python
# -*- coding: utf-8 -*-

if __name__ == ’__main__’:
    print("Hello こんにちは!")

$ ./
Hello こんにちは!

6. Must-have packages

I’m not a Python expert, and everyone’s needs are different so take this list with a grain of salt.

If you want to do web development, you could try:

Flask and Bottle are both excellent. Give both a try before deciding which one to use.

7. Python 3

Everything I’ve just said works for Python 2 or Python 3. Python 3 doesn’t come pre-installed on OS X, so if you want to install it, just use brew.

brew install python3

Then you can launch python3 and play with the new asyncio module:

$ python3
Python 3.4.1 (default, May 19 2014, 13:10:29)
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio

Python 2 and Python 3 can coexist without any problem. If you want to launch the Python 2 interpreter, just use python. If you want to use the Python 3 interpreter, just use python3; if you want to install packages in Python 2 library, just use pip, if you want to install packages in your Python 3 library, just use pip3….et voilà!!!.

You can create virtual env that will use Python 2 or Python 3, just use the -p option flag to target a specific Python. For instance:

mkvirtualenv -p /usr/local/bin/python3 testasyncio

Will construct a venv with Python 3.

8. IDEs on OS X

You can write Python code with vim but there are good and complete Python IDEs on OS X.

9. Various tools

9.1. Fabric

Fabric is a command-line tool for streamlining the use of SSH for application deployment or systems administration tasks. I use it for deploying this blog from my Mac for instance. With Fabric, you can launch command as if you were on your server, and execute arbitrary Python functions via the command line.

For exemple, in a file you code:

from fabric.api import local

def prepare_deploy():
    local("./ test my_app")
    local("git add -p && git commit")
    local("git push")

And then on the command line, you can launch:

$ fab prepare_deploy

And the commands will be executed locally.

But the real power of Fabric it that it can run commands on your server, from your Mac! For instance:

env.hosts = [’’]

def deploy():
    code_dir = ’/srv/django/myproject’
    with cd(code_dir):
        run("git pull")
        run("touch app.wsgi")

If you execute fab deploy, the commands will be sent from your Mac to your server (via SSH) and executed here! Fabric really simplify you deployment needs and you can deploy, run scripts on multiple servers easily. I use it to deploy the blog on our server, and we use it also to deploy our various Django projects.

From jc.

Joli Originals iPhone 6 Cases Available for Pre-Order NOW

In the midsts of all the Apple craziness, Jolien & Harold have announced new iPhone 6 cases available for pre-order NOW!

Joli Originals makes beautiful, handmade sleeves, from smooth premium Italian leather, with superb colors. They’re taking pre-order now for their iPhone 6 / iPhone 6 Plus model, and will start shipping the pre-orders on Monday the 22nd.


From jc.

Faux App, Analyze your Xcode Projects

What the Clang Static Analyzer is to your code, Faux Pas is to your whole Xcode project.

Faux Pas is an OS X application to inspect and check possible issues and bugs in your Xcode projects. From the features list:

Faux Pas is not only highly configurable and simple, but it also helps you to learn and enforce best practices on your code. I already use the Clang Static Analyser in combination with Jenkins, and I’m looking forward to integrate Faux Pas in our continuous integration build server.

A must for iOS / OS X devs!

From jc.

Castle of Illusion Starring Mickey Mouse

Castle of Illusion Starring Mickey Mouse is undoubtedly the best game I’ve ever played on iOS. The graphics are astonishing, musics are exceptional (use a headphone), and the gameplay is very good. I’m having so much fun playing it, it’s simply an exceptionally excellent game. A lot of love has been put in the development of this game; currently at $0.99, it’s a no-brainer, GET IT NOW!! It will comes back at $9.99 soon (even at that price, I still recommend it!)…

I have never liked the virtual gamepad used in some iOS games, but in Castle of Illusion, the virtual joystick just works. You will need good controls because the challenge is not easy. Besides, iOS 7 game controller support remains a promise unfulfilled promisses and a missed opportunity for Apple (anyone knows a good bluetooth game controller?). It’s also a real joy to play to a long, classic game, without any single one app purchase. A relief. Castle of allusion is also available on Android, but I’ve not tested it.

Like Zelda : A Link Between Worlds, the game is not just a HD remake of Castle of Illusion on Sega Genesis / Mega Drive, but a completely and reinvented game. Sega may have disappeared from hardware business, but I’m happy to see that they still have a future as games editor. And Sega and Disney seems to works nicely together (remember QuackShot?)

When I see this level of quality in iOS games, I fear for Nintendo.

Castle of Illusion screenshotAll graphics are now in beautiful, colourful 3D

Castle of Illusion screenshotMickey in the Cloud

Castle of Illusion screenshot

Castle of Illusion screenshotThe Castle

Castle of Illusion screenshot

Castle of Illusion screenshotYou first boss, a friendly old tree!

Castle of Illusion screenshot

Castle of Illusion screenshot

Castle of Illusion screenshotOne of the many puzzles: through the looking-glass

Castle of Illusion screenshotAnother boss!

Castle of Illusion screenshot

Castle of Illusion screenshotMiam miam, a sea of maccarons

Castle of Illusion screenshotThe green diamond is over here!

Castle of Illusion screenshot

Castle of Illusion screenshotA marshmallow dragoon!

Castle of Illusion screenshotHow cute are these littles sugars!

Castle of Illusion screenshot

Castle of Illusion screenshot

Castle of Illusion screenshotUnder the water, the vestige of an ancient city

Castle of Illusion screenshot

From jc.

Samsung Xpress M2875FW, a Really Good and Affordable AirPrint Laser Printer

If you’re looking for a good AirPrint laser printer and affordable, the Samsung Xpress M2875FW is for you. There are a lot of cheap AirPrint inkjets, but due to the price of ink cartridges, I have been looking for a good laser printer.

My wish list was:

After a lot of researches, I’ve found a printer that answers to each point of my wish list: the Samsung Xpress M2875FW. The Samsung Xpress M2875FW is an affordable (currently $189.99 on Amazon, subject to price change) multi-function printer, with AirPrint support, duplex printing and relatively small (15.8 x 14.3 x 14.4 inches / 40.3 x 36.3 x 36.6 cm):

Samsung Xpress M2875FW

When doing my researches, I tried to find how good was the support of AirPrint for each possible printer. I wanted to be able to have a built-in support, and I discarded any printer that allow printing only from a third party app. If you want to be sure that you future printer will support AirPrint out-of-the-box, my advise is to check this official list of AirPrint printers by Apple.

The Amazon page of the M2875FW indicates that there is a newer model, the M2885FW, but as this newer model was not listed on the Apple AirPrint support page, I have preferred to try and buy the M2875FW. The printer has been really easy to setup (on my MacBook Pro on Mavericks), you just have to launch the Samsung install CD and follow the instructions for AirPrint. Once the printer is installed on the MacBook Pro, printing from any iPhone or iPad is immediate, with no-setup. It’s kind of magic (like all the other Air technologies, AirDrop and AirPlay).

I’m really happy with my new printer and can’t recommend it enough. The only minus point is the cost of Samsung toners, that are above the average laser toners (around 10c / page); on the other hand, the M2875FW has an eco mode, but I haven’t finished a full toner to check the real cost.

Buy the M2875FW on Amazon - affiliated link

From jc.

Testing on iOS / OSX: There Is an Apple Framework for That

The new issue of is about Testing. Really a good new issue with a lot of interesting stuff. Being in the iOS development since 5-6 years, I’ve seen testing to be taken more and more seriously, if not by third parties, certainly by Apple.

But, man, 8 articles on testing on iOS, and not only one mention of UIAutomation, the core Apple framework for UI testing… Really?

If you want more information on UIAutomation (now spelled UI Automation by Apple), I recommend you the top read article on our blog iOS Automated Tests with UIAutomation. It’s a little dated, but I think it’s still a good base for learning UIAutomation.

What I love about UIAutomation is that it depends on accessibility: to be able to test your user interface, you have to make it accessible. So clever!

iOS Automated Tests with UIAutomation

Launching UIAutomation Tests in Command Line

Automated Static Code Analysis with Xcode 5.1 and Jenkins

From jc.

Import Cheetah3D Model in SceneKit

This article is really for 3D rookies like me that would like to play with SceneKit. SceneKit[1] is a high-level 3D framework, introduced in Mountain Lion, that allows reading, manipulating and displaying 3D scenes. SceneKit is now part of iOS, starting from iOS 8, allowing developers to easily integrate 3D graphics or develop 3D casual games on iPhone / iPad / iOther.

SceneKit supports the import of COLLADA scenes: COLLADA is an open XML file format for 3D assets, supported by a lot (if not all) 3D creation softwares (like Blender, Maya, Bryce etc…). If you’re new to 3D and just want to play with SceneKit, you can search for free COLLADA files on the web (*.dae), or use the ones included in Apple SceneKit samples (Vehicle, Bananas, or even the complete WWDC 2014 SceneKit session, available as a sample code!)

Besides using free models, you can also create your own using a 3D modelling tool: there are plenty of choices from free (Blender) to very expensive (Maya). On the mac, Cheetah3D is really an excellent, and not very expensive, alternative. For $69, you have a complete 3D modelling, rendering and animation software for OSX (buy directly on Cheetah3D web site or on the Mac App Store).

I’m just beginning to use Cheetah3D, and I really appreciate how easy is the creation of 3D models. Cheetah3D is also a native Cocoa app, with an intuitive, Macintosh-like user interface:

Cheetah3DCheetah3D on Mavericks.

Really a great software!

I’ve created this mug in a couple of minutes, following the first tutorial of Learn 3D with Cheetah3D 6, an excellent resource on Cheetah3D. To include this model in an iOS sample app, we need to first export it as a COLLADA file from Cheetah3D. Select File > Export, choose dae as File Format and save your file (or download it here).

Then, create a SceneKit sample, with Xcode 6: New Project > Single View Application.

SceneKit sample step 1

Give it a product name:

SceneKit sample step 2

Select the main storyboard of the document, Main.storyboard , then the ViewController scene, and remove the default view of the ViewController.

SceneKit sample step 3

Now, in the right corner of Xcode, select the Object library (as in the screenshot), and drag and drop a SceneKit view on the view controller.

SceneKit sample step 4

Now, some code! Open ViewController.m and add the following code:

@import SceneKit;
@implementation ViewController
- (void)viewDidLoad
    [super viewDidLoad];

    SCNView *myView = (SCNView *)self.view;
    myView.scene = [SCNScene sceneNamed:@"mug.dae"];
    myView.allowsCameraControl = YES;
    myView.autoenablesDefaultLighting = YES;
    myView.backgroundColor = [UIColor lightGrayColor];

We’ve just loaded our mug COLLADA file into the 3D scene view. Now, we need to import the file into our project: File > Add Files to "TestSK" and select our our mug.dae file. Then build and run:

SceneKit sample step 5

Mmmm… Something must be missing, we don’t have any textures displayed in the simulator! In fact, we forget something really important when importing our COLLADA files from Cheetah3D. In COLLADA files, textures are referenced and not included in the file; in other terms, the mug.dae file is not sufficient, and must be accompanied by the textures files that it references. So, we just need to include our mug-diffuse.png texture in our project: File > Add Files to "TestSK" and select the mug-diffuse.png file. Before running again the sample, you can select the mug.dae file in Xcode, and check that everything looks good now:

SceneKit sample step 6

Then, run the sample, et voilà !

iOS SimulatorThe mug in the iOS simulator

More on SceneKit

WWDC 2012 - Session 504: Introducing Scene Kit

WWDC 2013 - Session 500: What’s New in Scene Kit

WWDC 2014 - Session 609: What’s New in SceneKit

WWDC 2014 - Session 610: Building a Game with SceneKit

From jc.

  1. Spelled "Scene Kit" on Mountain Lion and Mavericks, and "SceneKit" on iOS 8 / OSX Yosemite 

Of Tab Bars

Tab bar is a standard navigation control present in iOS, since the first introduction of the iPhone. In the iOS Human Interface Guidelines,

A tab bar gives people the ability to switch between different subtasks, view or modes in an app.
Use a tab bar to give users access to different perspectives on the same set of data or different subtasks related to the overall function of your app.

In general, use a tab bar to organize information at the app level. A tab bar is well suited for use in the main app view because it’s a good way to flatten your information hierarchy and provide access to several peer information categories or modes at one time.

From gradient to flat

Tab bar has survived the iOS 7 shake-up, with minor modifications. From iOS 5 to iOS 7, the clock app tab bar’s looks like this:

Clock Tab bar EvolutionEvolution of Clock’s tab bar from iOS 5 to iOS 7

Until iOS 6, tab bar icons were computed by applying a template blue gradient on a monocolor shape:

Classic tab bar icon

Looking closely, rendered icons also included a drop shadow and a light glowing stroke:

Favorites icon

All third-parties apps using a tab bar exhibited the same blue bar icons (maybe with the noticeable exemption of the Nike+ app): there was no easy way using public APIs to change the icon blue rendering.

On iOS 7, the blue gradient is dropped to a flat, plain and customisable color (aka key color in iOS Human Interface Guidelines or tint color). Now, the clock tab bar looks like:

Clock Tab bar on iOS 7

Appart from minor design modifications, the tab bar uses now two templates images for each icon: a selected/active one, and an unselected one:

The unselected icon is often just a thin silhouette of the selected icon. The selected image has more plain zone, filled with color: the attention is really focused on the selected icon. Another gain with the iOS 7 design is accessibility: even if you’re color blind, you can still see where is the selection.

Forgetting to use two different icons for the two different states is really a common mistake in a lot of iOS 7 apps (maybe due to the fact that you can’t use Interface Builder to set the image for each state). Programmatically, it’s straightforward using UITabBarItem instances:

NSString *imageOffName = @"ClockTabIconOff";
NSString *imageOnName = @"ClockTabIconOn";

tabBarItem.image = [UIImage imageNamed:imageOffName];
tabBarItem.selectedImage = [UIImage imageNamed:imageOnName];

iOS 6 experimentations

On iOS 6, a simple app built with the public SDK kept using the classic blue gradient. But some Apple apps showed that there were ’experimentations’ around where should go the iOS design. For instance, the App Store app used a ’flatter’ gradient, while keeping the blue selection against a black background:

AppStore Tabbar EvolutionApp Store on iOS 5, 6 and 7

In the same time, the Music app used a completely greyed tab bar:

Music Tabbar EvolutionMusic on iOS 5, 6, 7. Notice the black pixels in the bottom corners to give a "rounded" layout" in iOS 6.

Combine the new flat color selection of the App Store app and the lighter tab bar of the Music app, and we have something that can resemble to the iOS 7 aesthetic! What’s surprising is that the iOS 7 tab bar, while being a real departure from the past, has kept a familiar look and feel, and could be seen as another design iteration.

Back to basics

How to talk on tab bar and not mention Game Center? Introduced in iOS 4, Game Center (and more precisely the Game Center companion app) was the first built-in app to not use the classic blue icon / black background tab bar. It featured a rich faked wooden tab bar. Four releases latter, iOS 7 has come and put the Game Center app on the right track (more consistent, less fun):

GameCenter Tabbar Evolution

From jc.

Official Apple Swift Blog

Another proof that Apple is changing, this dedicated blog on Swift. Swift is in flux, and there are some important changes to the syntax before the official 1.0, so bookmark this official feed.

Already good advises in the second article on compatibility:

This means that frameworks need to be managed carefully. For instance, if your project uses frameworks to share code with an embedded extension, you will want to build the frameworks, app, and extensions together. It would be dangerous to rely upon binary frameworks that use Swift — especially from third parties. As Swift changes, those frameworks will be incompatible with the rest of your app. When the binary interface stabilizes in a year or two, the Swift runtime will become part of the host OS and this limitation will no longer exist.

Beware of this issue: while the binary interface is not frozen, all components of your app (especially Swift framework that you don’t have the source code) should be built with the same version of Xcode and the Swift compiler to ensure that they work together.

From jc.

Zen and the Art of the Objective-C Craftsmanship by Luca Bernardi and Alberto De Bortoli

The idea underneath is that the code should not only compile, instead it should "validate". Good code has several characteristics: should be concise, self-explanatory, well organized, well documented, well named, well designed and stand the test of time. The main goals behind the curtain are that clarity always wins over performance and a rationale for a choice should always be provided. Some topics discussed here are general and independent from the language even if everything is tied up to Objective-C.

Zen and the Art of the Objective-C Craftsmanship is really a good book on Objective-C guidelines. Cocoa is full of conventions: if you’re an experienced iOS or OSX developer, you’ll already know most of these best practices; but I bet you’ll also learn two or three things you didn’t know (great discussion on blocks and retain cycles on self).

Luca and Alberto started writing this book on November 2013. But now Swift is the future of Mac and iOS development so they decided to release the current version of their book. Great work (via Dave Verwer’s iOS Dev Weekly).

From jc.

Social Login Buttons Aren’t Worth It by MailChimp

Quite funny, we just have this discussion this morning: we ask ourself if one should propose a Facebook or Twitter login while designing a new login page. MailShimp in Social Login Buttons Aren’t Worth It gives some really good reasons (and analytics) not to use social login buttons:

Sometimes you log in with Twitter, sometimes with Facebook, sometimes with a username and password specific to that app. It’s hard enough to remember your username and password, let alone which service you should bloody use to log in. As you add login buttons to a page, you also add decision points for users, while creating visual complexity in your design. The marginal gains in login rate are chipped away by the additional cognitive load you’re adding for your users.
Is it worth it? Nope, it’s not to us.

From jc.

All Posts