Good vibrations

Hi !  I was recently asked to make the iPhone vibrate while using the app (not by notification).  It’s been a while since I had to do it and back then it was in Obj-C. Here’s how to achieve it in Swift:



Xcode crash, Storyboard Container Extension

Is it just me or Xcode isn’t the piece of software it used to be ?  I mean, it’s never been awesome but recently I crash it 2-3 times a day.  Not to mention the two fingers swipe ( for back & fwd ) that also breaks often.  I expect the same software quality from Apple that my clients expect from me.

Sorry its been a while here it is :

The Extension of the month

Simple but handy


Closure in Swift: A reminder on how awesome they are.

I was re-reading Apple’s documentation about closure and I tough it couldn’t hurt anybody to share this little resume about closure syntax.

Here’s a simple closure :

Here’s the same but simpler :

Hmm even simpler :

Huh ?!? Even more :

WTF ?!?! Really ?! (but yeah it works) :

And finally (unreadable but still) :

From The Swift Programming Language (Swift 3.0.1)



UIViewController extension for child view controller containment.

Hello !  I know its been a while, holidays and all …

Here’s a little extension that does no magic but shortens your code if you have to load child view controller from storyboards.  Sorry for the lack of syntax colouring, WordPress does not seem to support Swift yet.

[code language=”text”]
import Foundation

typealias ViewControllerStoryboardInfo = (name: String, id: String?)

protocol Container {

extension Container where Self: UIViewController {

func addChildViewController(withInfo info: ViewControllerStoryboardInfo)-> UIViewController? {

var viewController: UIViewController! = nil

switch {
case let identifier where identifier != nil:
viewController = UIStoryboard(name:, bundle: nil).instantiateViewController(withIdentifier: identifier!)
viewController = UIStoryboard(name:, bundle: nil).instantiateInitialViewController()

if let viewController = viewController {

viewController.view.frame = self.view.bounds
viewController.didMove(toParentViewController: self)
return viewController

return nil

func removeAllChildViewController() {
self.childViewControllers.forEach({ (controller) in
controller.willMove(toParentViewController: nil)




It’s free pub for them but they certainly deserve it !  All of you dev out there you need to try this.  Pick you project PSD or Sketch, import it and enjoy.

  • Easy asset integration
  • Code generation for UIColors and UIFont extensions used in the PSD
  • Measurements for everything in point ‘pt’
  • Comments on UI elements between users

Downside … a little bit expensive in my humble opinion.



Xcode server and Cocoapods : Your local changes to the following files would be overwritten by merge.

Hi all,

Sorry for the delay, I have been busy building up a Swift 3 framework for OpenGL and Vuforia.

Back to our main topic.  I recently built an Xcode server for my project.  The project uses Cocoapods and for a time it was good then, a few days ago, a build exited with the error :

Your local changes to the following files would be overwritten by merge.

And has been failing ever since until I found the solution.  It seems the cocoa pods repo gets messed up sometime and you need to hard reset it to HEAD.  Here how :

cd ~/.cocoapods/repos/master

git reset HEAD –hard

Takes a couple of minutes and then you should be just fine !

Enjoy 🙂


Bring you app to life – A very simple guide to animated buttons and backgrounds

Hey !

I know its been a while, I am qui busy at Moment Factory right now.  Those guys are geniuses.  Anyway, I wanted to share with you, if you don’t already know it, how to animate anything that uses a UIImage aka. UIImageView, UIButton, etc…

To create an animated UIImage, include in you project a folder that contains your animation with a PNG for each frame.  The files needs to be named like this:

  • WhatEverNameYouWant-1
  • WhatEverNameYouWant-2
  • WhatEverNameYouWant-3
  • WhatEverNameYouWant-4

I strongly recommend not to include these in an asset file, if you try you’ll quickly understand why.

Then you create a UIImage :

You can the use it with a UIButton like you would with any other UIImage :

That’s it !  Have fun animating you apps !!