Time for Xcode to Grow Up

Apr 17, 2014

It is fair to say that Xcode has gotten immeasurably better since the early times of Xcode 4. Long forgotten are the days of selecting a different /Developer directory to install Xcode betas. Soon forgotten will be the days of random crashes. Everything seems reasonably snappy, you don't have to wait 15 seconds if you hit CMD-T on accident (or on purpose).

The whole system seems much more predictable. That said things are not perfect. You still don't want to press a button that says Fix when it comes to provisioning, because (spoiler alert) it doesn't fix your problem. Sometimes restarting Xcode fixes random things, sometimes you have to sweet talk Xcode* into compliance.

Since Xcode has stabilized so much people are tentatively optimistic about its future. We are currently in a Renaissance of Xcode plugins. Unfortunately, the best plugins have yet to be written. Companies are hesitant to build plugins because there is no official support from Apple. Every new version of Xcode is likely to break your plugin. As a company it is difficult to do capacity planning if there is no official api or support from your platform owner.

A formalized system benefits apple in a few (mostly theoretical) ways:

  • If developers are able to be more productive, they can spend extra time creating more amazing things for the platform.
  • The more comfortable developers are using a tool, the less they want to switch. Creating voluntary vendor lock in for mid to junior developers.
  • If a company had an official Xcode plugin you can be sure they would put an Xcode logo on their website, subtly extending apple's brand.

But I think an official plugin api for Xcode is highly unlikely. Apple has a track record of supporting people who make apps, but not people who support app makers. Helping tool makers doesn't make Apple more money, in the short. Not having to support an official plugin architecture allows them to iterate more quickly. If I were running Apple I might make the same choice. But I still pine for a streamlined workflow that supported plugins could partially provide.

* this doesn't work, I've tried

Time for a change

Dec 14, 2013

I have been in the DC area for 9 years. It is the longest I have lived anywhere in my adult life. I can't believe it has been that long.

DC has been amazing for me. I have made lifelong friendships. I was one of the first employees at Taxi Magic. I started my own business. I changed my career direction multiple times for the better. I attended the 2008 Obama inauguration when people were excited. I was able to do things I never imagined being able to do.

I say all that because when people relocate, I think there is a tendency to think they were unhappy. I was not unhappy. That said DC is a place that is difficult to call "home." It is big and people are constantly leaving (now I am one of them). I am mostly looking for a place that is a bit smaller with a bunch of new adventures.

Starting in March, I am going to be calling Portland, OR home. I have been there on multiple occasions and have loved it. I am looking forward to exploring the west coast for a while. If there is someone you think I should meet, please do an intro I would like to have a few more friends when I get there.

Some things are not changing though. I am still going to be running 2 limes, my consulting company. I am still going to be pursuing my own commercial and open source products. My day to day will probably not be changed, which is good since I am happy.

Keep being awesome and call me up if you are going to visit Portland.

Linkage

Dec 14, 2013

A childhood dream

Like many teenagers, I loved video games. When it was time to decide what I was going to do with my life, I thought it might be fun to make video games for people. So, I studied software, I built things, and somewhere along the way I stopped playing all but the most casual video games. This year when Apple announced SpriteKit, a 1st class iOS game framework, I decided to follow through on that dream.

The game

Linkage 1
Linkage 2

Linkage is the type of game I play now. Super easy to start playing, the longer you play the better you get. It feels like if you play longer you will get better at it. There is some strategy to it and you can get a better score by thinking. Most importantly, you can't buy your way to a better score.

The general game play is inspired by Bejeweled. You swap and rotate tiles a make connections. There are two game modes. One is for people who like to go faster and be pressured. The other is for people who like to think. I think they are both fun. I would be honored if you would play it and let me know what you think. It is free so have fun.

Lapse the World

Oct 18, 2013

Origin Story

I am excited to announce my first new personal project in awhile. It is called Lapse the World. It is a app for making time lapses on your iPhone. It is my first (completed) project that involves AVFoundation. It took me way out of my comfort zone in the best possible way.

It started as a proof of concept because a job required me make extensive use of a framework I wasn't comfortable with. I didn't end up getting the job for a variety of reasons. I did end up getting a taste for audio and video programming. It is different than the usual consume web services and do something on the device. My friend calls this type of programming being a "bit dump truck driver".

I knew I wanted to finish this project, I also knew that I sucked at finishing things on my own. I recruited my friend, Seth, to help with the code and keep me motivated. Between the two of us we were able to wrap this up and get it launched.

Lapse List Screen

Lapse List Screen

Recording Setup Screen

Recording Setup Screen

The Recording Process

Many time lapse apps record the video in real time then compress it later. This is good for some reasons and bad for others. The best part about this approach is that you can choose how fast to make the video look after it has been recorded. The downside is that the recording is stored in it's original size which is a deal breaker for me since the iPhone is storage constrained.

We decided to go a different route. We let you specify a number of different compression ratios before you start recording and only record the frames that are needed. A normal video is recorded at 30 frames per second. Say you want to make a recording that appears 30 times faster than real time. So, we grab 1 frame per second instead of 30. Then when you play the video back, you view it at 30 frames per second making 30 seconds fly by in 1 second.

We are allowing you to pick up to 3 compressions while you record, because if you are like us, you don't really know what compression to use to make it look cool. As you can see in the above screen shot, we have a couple presets and a way to customize it if you want to experiment, or know what you are doing.

Other Stuff

We decided to make it free with In App Purchase. Enough digital ink has been spilled talking about app store pricing and the race to the bottom, so I am not going to go into further detail about it. But suffice to say, since Seth and I don't have huge internet followings, we thought it would sell better if it were free and people could pay to export their videos after they have tried it out.

Seth also build a custom video scrubber that shows frames from your lapse. It is awesome and Seth will be open sourcing it shortly. For time lapses, it isn't that cool because most time lapses kinda look the same throughout the video, but if you use Lapse the World while you are driving or something the scrubber should help you see different parts of your video while you are scrubbing.

Finally

If you make any lapses with the app drop us a line we would love to see them.

Real Quick: Template Images

Oct 15, 2013

iOS 7 introduced the concept of image templates. This builds on the idea of an app having a tint color. When you use a template image any nontransparent pixels get colored to your application's tintColor.

In order to support this concept UIImages have the concept of renderMode. There are three unique render modes:

  • UIImageRenderingModeAutomatic
  • UIImageRenderingModeAlwaysOriginal
  • UIImageRenderingModeAlwaysTemplate

As you can guess, automatic is default. In the documentation, Apple says that automatic render mode is context sensitive. The context in this case is the type of UIKit element the image is rendered in. For instance, UIBarButtonItems render in template mode when you use the automatic render mode.

The general rule is that if you are interacting with the element, automatic mode will probably render as a template. Elements that follow this rule are:

  • UIBarButtonItem
  • UISegmentedControl
  • UIButton (foreground images)

One borderline exception to this rule is background images for UIButtons. They act like UIImageViews, automatic mode acts like original mode.

Overall it is pretty straight forward. Below are two images showing these items rendered with different tint colors and only 1 image packaged. I shared the code for this post github.

Blue Tint Color

Blue Tint Color

Red Tint Color

Red Tint Color

Xcode Asset Catalogs

Oct 01, 2013

Basics

This year at WWDC Apple introduced Asset Catalogs. Asset Catalogs are meant to reduce clutter in your project navigator and bring clarity to how images are being used. The idea is that instead of having all your images listed out, you have one or more asset catalogs in which you can drag and drop the images into the correct spot.

Asset Catalog

In addition to using it for the app icon and launch images, you can use it for arbitrary images. Images can be used universally or device specific. This is super handy because you don't need to remember all the file naming conventions for iPhone vs iPad vs retina vs 4inch vs etc.

Universal

Universal Asset

Device Specific

Device Specific Asset

Slicing and Resizing

Asset Catalogs also allow you to do slicing. This tells iOS and Xcode how to stretch the image when the view it is filling is larger than the underlying image. This functionality has always been supported in iOS with a few different methods on UIImage the most recent is resizableImageWithCapInsets:. One big improvement is that Interface Builder will now show the stretching maintaining the insets correctly. As always, the images can be stretched vertically, horizontally or both.

One thing that is actually great about slicing in Xcode is that the designer can provide you an image as wide as they want. You don't have to explain to them how slicing off end caps and a middle two pixels works. After some quick tests, I have determined that Xcode produces the smallest image in needs at build time. Which means it is slicing off all the unneeded bits before it packages it for you. That leaves you with the best of both worlds, when you look at it in Xcode it looks big, but it packages the minimum amount needed.

For reference here is Apple's guide to image slicing.

Technically

I haven't dug into this too much but it looks like all your Asset Catalogs are being put into one file called Assets.car. I don't know the specific binary format being used to pack all the images and slicing data, but I would guess one advantage would be that you don't have wasted block fractions. As you probably know the smallest amount of space you can allocate to a file is 1 block. Since the block size on iOS is 8k, if an image is 12k, it takes up 1.5 blocks, leaving half a block wasted. Multiply that by 1000 images and are talking about a real savings. That will speed up download times for your users. UPDATE: Daniel Jalkut points out in these tweets (1, 2) that the app is delivered in 1 zip file, so this will not help download speeds.

There is some overhead associated with loading Asset Catalogs. I would guess that the app would load all your assets into memory, this could lead to having images in memory that aren't being used. That said, you probably don't have enough images to be problematic. One important thing you should be doing anyway is removing unused images. I use a the Slender Mac app. It doesn't support Asset Catalogs yet, hopefully in the future it will.

Updating and Diffing Images

The biggest issue I have with Asset Catalogs is updating images. Many times when I am working with a designer they will iterate 2 to ∞ times to make sure the app looks and feels perfect. Typically I will get a new set of images from the designer and drop them into the project and start using them. As far as I can tell, you have to drop the image into the correct box in the Asset Catalog if you want to update it, which is less than ideal. Currently, I don't have a simplified solution to improve the new workflow. Since the point of Asset Catalogs is abstracting away the file name conventions, I don't see how Xcode would know where to put those images.

Another issue is diffing. You used to be able to look at the the old image and the new image side by side in Xcode's "version editor." With Asset Catalogs it shows the whole catalog as different even if only 1 image has changed. This is mostly a non issue for me since I use Black Pixel's Kaleidoscope for all my diffing needs. Kaleidoscope still diffs the images as good as ever. But it is a bit of a drag to not be able to glance at the project navigator to see what has been changed.

Localization and Translation

Images get localized and translated like other things in the application. At this point I don't see a way to localize Asset Catalogs. This is probably not that big of a deal because image localization should only occur when an icon means a different thing in a different country. That happens, but not enough to let it stop you from using Asset Catalogs. If you do need to translate an image you can do it the old way.

iOS 6

This is mostly a non issue since most people are going iOS 7 only so quickly. But if you choose to target iOS 6 for backwards compatibility, it will include the Assets.car file and all the image files. I didn't research how this would affect the resizing. It doesn't really matter, because if you are targeting iOS 6 you probably shouldn't use Asset Catalogs due to the increased app size.

Somethings Do Not Need To Be Uberified

Aug 26, 2013

I was reading the article, Uber for Everything. The idea is that if you have a drill (or whatever) you aren't using, you can rent it out to nearby people and make a little coin. In addition to that some middle man can shave a few percent off the transaction and get rich. What could be better?

Some of the stuff in the article make no sense. The first example is a drill that costs $22. It would probably cost 1/4 that just to transport it over. Then you have the middleman's cut, then you have whatever money the owner is going to make. Probably not a good candidate for a marketplace.

Another example is Dinner set for 12 people on a friday night. A much better candidate, but who wants to rent out their dinner set to strangers? Presumably you like your plates (because you bought them). If one plate gets broke while your friends are over, you can excuse that, because you probably like your friends too. But if a person renting the plates from you breaks a plate whatever amount of money you get in compensation is not going to make up for the fact that you now have an incomplete set.

I think a better fit for this problem a community driven co-op. Where the government seeds a new organization with a $100k. This would allow them to buy a few of every item they want to rent out. Community members could pay a small monthly fee to be a member of the co-op. In addition to the fee if they broke anything they would be liable for paying to replace it (based on depreciation values). The monthly fee would go to running the staff and essentially replacing items and adding new items as needed. It would work similarly to a library, If you check out dishes on friday, you have to bring them back clean on saturday so your neighbors can use them.

I just can't see a world where we need to create a marketplace for everyday things. That said, I also don't want to have a hammer or drill in my house, so someone get on this co-op idea.