Category Archives: Mac OS X

My Tribute to Steve Jobs

Steve Jobs inspired me to make apps for the Mac, quit my job and start my own business.  He created the mobile apps industry where I now mostly make my living.  Apple under Steve Jobs set the gold standard for smart phones, tablets, customer experience and even presenting on stage.  I feel fortunate to have felt his RDF (Reality Distortion Field, a shorthand for witnessing his charismatic personality and passion in person) at the “Stevenotes” at WWDC, which I have attended since 2005.

It seems incredible now that with Steve Jobs at the helm, that Apple has gone from a struggling company to being the most successful one today.  It seems normal now to stand in line for Apple products on launch day in front of the Apple Retail Stores, but before they opened, having a retail presence was thought of as a liability.  It seems normal now to have touchscreen phones, but before the iPhone was released, people used to think a hardware keyboard was necessary.  It seems normal now to have a tablet, but before the iPad was released, people didn’t think that they would want or need what seemed to be just a big iPod Touch.

But Steve Jobs was a visionary.  He brought us the future and made it real.  Especially in the past 10+ years, he has pushed the entire tech industry and perhaps the world forward in terms of technology.  He will be missed, but his legacy lives on in the products that we use today.

(Note: I originally posted this earlier today on the Happy Apps blog as Steve Jobs – He Made the Future Real, but I thought it was important enough to repost here.)

Fixing SASL For Colloquy When You Are Using A MiFi

I got a MiFi the other day.  It has performed great so far, with the exception of IRC.  Why use IRC you say?  Well, here in the DC area, we have an active Mac, iPhone and iPad programmer group called NSCoderNightDC and when we’re not meeting weekly, we like to meet online.

However, on my new MiFi, I kept getting a strange error when firing up Colloquy: “Notice — You need to identify via SASL to use this server”.  There’s a ticket for that: #2590 Sasl Support? There’s a fix already, but not in anything released.  The latest nightly is from late last year.  But hey, that’s the beauty of open source!  Just download, compile and go.  So that’s exactly what I did and what you can do too if you run into this problem.  Here’s three easy steps:

1. Download the source

I like to use git.  Colloquy uses Subversion.  Git-SVN to the rescue:

git-svn clone -s http://source.colloquy.info/svn/ colloquy

The “-s” is to make it use the “standard” format of svn, which has trunk, branches, tags.  My friends at Viget have written up more info about git-svn that I use as a reference.

2. Download the latest F-Script

3. Copy FScript.framework into ~/Library/Frameworks

4. Open up the “Old” Colloquy project

open Colloquy\ \(Old\).xcodeproj/

I tried all the other projects and while they built successfully for me, they didn’t seem to work and the main menu was not fleshed out.

5. Build

This will probably take a while.  Note that I used Xcode 3 to build.

6. Run and enjoy your SASL-enabled, MiFi-compatible, Colloquy hand-built from source.

Note that you will probably be asked to update to a “newer” build.  Don’t do it and overwrite your hard work.

BTW if you’ve tried all these steps and still can’t get it to build from source, you can download my latest build of Colloquy that is SASL-enabled and MiFi-compatible.

UPDATE: @rudemateo tried this at NSCoderNightDC while on my MiFi and it turns out you need to register your nick and supply it in the Connection info or else you get that SASL error still. He did it by getting the Colloquy iPhone app, then he was able to log in with the build above on his Mac.  Also, @atomicbird has a 3G MiFi that isn’t affected, so perhaps it is isolated to Verizon’s 4G LTE network.

C4[3] Blitz Talks and MacRuby

I just came back from C4[3] – an Independent Mac and iPhone Developer Conference in Chicago. Wolf and Victoria host it and I saw Daniel Jalkut helping out along with a few other folks. In case you’re not hip to the zero numbering scheme, this is actually the 4th iteration of the conference. I went last year to C4[2] and this year was even better in my opinion.

There’s too many things to write about so I’ll just focus on two things that stick out in my mind: Blitz Talks and MacRuby.

I go to NSCoderNightDC and we have a nice core group of Mac and iPhone Devs who show up every week and eat Strawberry Napoleons. We also code and talk about design. Well 3 of the guys proposed Blitz Talks and got accepted.

Rob hit it out of the park with his Briefs iPhone prototyping tool. Jose actually created a Brief on the way from the airport to the hotel. He was kinda nervous beforehand in the hotel room but he practiced his presentation a few times on me and was really well prepared. His slides were top-notch but I think the idea is what really captivates people. I’m personally a big fan of fake-powered prototypes – prototypes powered by objects that return canned responses, but I’m definitely going to try out Briefs on upcoming iPhone engagements.

Jose did well with his presentation about the different types of contexts that an iPhone user would use different apps in. I’ve seen him give this talk before so it was interesting to see how he pared it down to fit in the much tighter 5 minute time frame.

Mark gave an interesting talk about how to do video right for Mac and iPhone screencasts and demos. I have a lot to learn about this and I’m hoping to work with Mark on a screencast sometime in the near future for Webnote.

There were many other Blitz Talks and I think they really were a nice Change of Pace that I haven’t seen in other conferences. Wolf amped it up even further by providing an animated radar / pie that kept filling up as the talk progressed.

MacRuby was the other big surprise for me. I had been tracking RubyCocoa and had seen the early MacRuby demo at RubyConf 2007. I’m a former Smalltalker and current Rubyist. I do all my automated build processes in Ruby and I’ve also created various non-Rails Ruby server-side components for clients. Plus I did Ruby on Rails for a few years. So I’ve been wanting to make Mac apps with Ruby, except one thing kept holding me back: I don’t want to show everyone my source.

Obfuscation is not a problem with server-side Ruby. The users only see what you expose via the web or other ports. They only see what’s rendered to them or the API that you expose.

Client-side Ruby is another world altogether. Users learn that they can peek inside application packages and if you’re writing Ruby, they can see your source. I’ve asked this question at WWDCs in the past and the answer was usually that its not a big deal and that you should just keep innovating. But we don’t just leave our Objective-C sources lying around, do we?

MacRuby will soon solve that, or I hope it will, with his AOT (Ahead Of Time) compiler. Or as it is known in the C/C++/Objective-C world: a compiler. LOL. So with the AOT, we will be able to write Cocoa apps in Ruby, compile them and run them on Mac. (And maybe iPhone – the jury is still out on that.) Which means that people can’t just look at your Ruby source. Even better, there is the HotCocoa project which provides useful macros / shortcuts for common Cocoa idioms.

Why use Ruby to write Cocoa apps? Ruby can be more concise, there are more libraries to choose from and the testing/mocking frameworks are better. On the other hand, the debugging story is still hazy.

I’ll be trying out MacRuby soon and I’ll post what I find. They’re currently at 0.4 with a 0.5 on the horizon, with nightlies for Snow Leopard available and the latest source available in both Subversion and Git.

Getting Sparkle from source (using bzr as compared with svn and git)

A few notes about getting Sparkle, the widely used framework for updating Mac OS X apps, from source:

1. Get a branch. This is similar to “svn checkout” or “git clone”.
bzr branch lp:sparkle

I admit it is kind of cool to have such a short name here like “lp:sparkle” due to bzr’s integration with Launchpad, which is sort of like SourceForge or GitHub.

2. Later on, you might need to get the latest version. This is similar to “svn update” or “git pull”.
bzr pull

3. To make sure you have the latest, you can check what version you have. This is similar to “svn info”. The closest to this in git is “git log –max-count=1″
bzr version-info

You can compare that version to the latest one in the main Sparkle branch.

Three things I learned at WWDC 2009

I went to WWDC 2009 last week and I learned 100 things. Unfortunately, 97 of them are under NDA, so I’ll just share with you three things that aren’t secret.

1. When in doubt, file a bug.
Mac OS X and iPhone to some extent are a democracy, where bugs count as votes. Apple uses your bug filings to see which things should get fixed and which things should get implemented. I’d say at least half of the Q&A could be summed up by: “Please file a bug.”

At first it seems like the Apple Engineers are just passing the buck, but really what they’re saying is either:
a. “Yes that seems like a good idea, but I need you to file a bug so I can justify working on this, be it a bug or a new feature, to my manager.” or
b. “I’m not sure about that, but file a bug and if we get enough of those, we’ll work on it.”

BTW here’s how to file a bug in Apple’s Radar bug database.

2. Instruments is as important as Xcode and Interface Builder.
Every Mac and iPhone Developer is familiar with Xcode and Interface Builder. But Instruments is just as important, especially with the relatively limited hardware of the 1st gen/3G iPhone and 1st gen iPod Touch. There were a lot of good sessions that featured Instruments that are worth watching when the session videos come out.

Even on Mac OS X, profiling your application to improve its performance and memory usage is important to do with Instruments.

Another interesting tool to delve into is dtrace. Its the technology that underlies some of the instruments in Instruments.

Also I heard a new phrase “There’s an Instrument for that.” If you have access to the Snow Leopard betas (and you should get it via ADC), then check out the new ones that are available. If you don’t see one that fits your needs, you might consider filing a bug requesting it.

3. WWDC 2010 will hopefully occur in a bigger venue.
WWDC 2009 sold out the fastest as I’ve seen any (and perhaps the fastest ever?) 60% of attendees were new attendees. So there’s still another 3000 or so people who were at WWDC 2008 and previously that might have attended if they had purchased their tickets sooner. Add to that another 2000 or so developers that see the market growing due to the $99 iPhone and you’re over 10,000 developers that could be attending WWDC 2010. That’s roughly double the attendance.

OK I admit that I don’t really like lines and such, but the keynote line ran completely around the block back to the front! Moscone West was just overflowing with Mac and iPhone developers this year. I’m hoping that next year’s WWDC 2010 will be say in Moscone South or Moscone North. It might not be as cozy but it should give some breathing space and allow for more developers (including those who have longer purchasing cycles) to attend.

10 Things I Learned from C4[2]

I went to C4[2] last month. For the uninitiated, C4[2] is the third (yes we count from zero) conference of its kind, a conference for independent-minded Mac and now iPhone developers, held annually in Chicago, Illinois. It is run by Jonathan “Wolf” Rentzsch, who is an independent Mac / WebObjects consultant.

It was a great gathering and I look forward to going to C4[3] if I have the opportunity. So I thought I’d share my top 10 things that I learned at the conference:

1. Getting like-minded developers together at one place generates a lot of energy, enthusiasm and knowledge sharing.

I think it’d be great if we could replicate what has been happening in the Ruby community and start to have Regional Objective-C conferences. This has started to happen with the iPhone Dev Camps already, but it’d be great to have combined Mac / iPhone Regional conferences, so devs that can’t afford to travel to Chicago and San Francisco can still get involved and interact with each other in Washington D.C., New York, Seattle, Denver, and wherever else we all are.

2. iPhone development has really come into its own, but its knowledge continues to be restrained by the NDA.

We started off with a presentation by Craig Hockenberry of how iPhone has changed the way humans interact with computers in much the same way the mouse did. We ended with a programming contest called Iron Coder (a play off of Iron Chef) which traditionally has been with Mac OS X APIs but this time was on iPhone with an iPhone API. I finally participated (after helping with past Iron Coders by providing licenses of WebnoteHappy as prizes), collaborating with Joe Pezzillo to produce CoreParanoia and also contributed a tiny bit to Jose Vazquez‘s 2nd place Tipster.

The rest of the presentations were not iPhone focused, but there were mentions of it throughout. And it seemed like having an iPhone was part of the requirements for attendance. I personally got a live demo from Tim Burks of his iPhone app Masyu which is a pretty fun puzzle game.

The problem however was that the NDA on iPhone development stifled a lot of the conversation. This generated a lot of complaints and even a t-shirt that rebelled against it.

3. Security is scary, but not as scary as not succeeding.

There was a wild presentation on security that said: don’t pretend to be a security expert. Stick to using the Keychain or bcrypt for passwords, use openssl or gpg. Don’t use installers or open up listeners on ports. Don’t write directly into the DOM. But all of that doesn’t matter if your business doesn’t succeed if you don’t have a nice looking application and it is unstable or slow. Also, filter user-supplied content and write a fuzzer for the content you accept. Make sure you have a security contact, use a crash reporter, and use auto-update securely. Finally, turn off Java in your web browser to prevent against some of the newer, crazier attacks like GIFAR.

4. Mac users really care about user experience (as if you already didn’t know that.)

To reiterate what we all sort of know but sometimes overlook since we are so deep in our code, Mike Lee presented “Pimp My App.” The basics: Use real artists, don’t skimp on your art budget, watch real users use your app, solve a specific problem, and cut as many features as you can.

He also offered some iPhone specific UI tips: start as fast you can, the start-up screen should not be used as a splash screen but more like the real app, restore the state of your app instead of just restarting, don’t block the UI, and think about the user’s first experience carefully.

5. Contractors / consultants are Indies too.

I’ve made applications and I’ve done consulting. Both qualify you to be an Indie, meaning independent from another company. There was a presentation by Andy Finnell on this and it mostly reiterated what I knew but it was nice to hear it from someone else. Basically: make sure you have good contracts, these will help you get paid properly and avoid constraints your future development. I’d add to this that if you can be choosy, it is good to figure out what kind of clients you want to work for and what kind of projects you want to work on and then only choose those to work on, even if it means taking some time off between projects.

6. Pricing sends a message

Rich Siegel of Bare Bones gave a presentation on lessons learned over his career. One of the key ones is that pricing: is a marketing message and shows how you feel about your product. It also needs to consider how much your overall costs are. It also positions you among competitors. That being said, your product / service definitely needs to be differentiated to justify a premium.

7. Warnings should be fixed

This is probably also a no-brainer but I’ve been at a few companies / projects where warnings are tolerated. Mentioned by both Rich and Mike, warnings can be the cause of run-time errors down the road. Its best to generate the most warnings possible and fix them as they come up. You may find it also advantageous to treat warnings as errors, but either way way, fix them.

8. Mac programmers really care about fonts

Minor but revealing tidbit: the fonts at C4 are carefully chosen. Compared to other conferences I have been to, I think this shows that Mac programmers care about design more than other programmers.

9. Twitter is the preferred method of communication in the Mac / iPhone developer community

When I wanted to see what was going on and what people were thinking, I checked Twitter. At other conferences, sometimes we would have IRC back-channels. Using twitter makes the back-channels more open. Also, we voted for Iron Coder via Twitter.

10. Do the simplest thing possible

Mentioned by Craig, Buzz Andersen, and Mike, doing the simplest thing possible, getting feedback and then iterating on that is a good technique when developing products. I knew this before, but many of us are perfectionists and so we have to keep reminding ourselves of this in order to combat the tendency to either add more features or to keep trying to perfect a certain specific part of our app.

Generating random numbers in Cocoa

I’m writing an application to pick prize winners for the RubyNation conference that’s coming up here in the Washington DC area. As part of that, I have to generate random numbers. So I went looking for how to generate random numbers in Cocoa. I was looking for something reasonably fast, built-in to Mac OS X, had an easy to use API, and had the most randomness. I defined a random number generation algorithm as being more random if it had a larger range of numbers that it could generate.

The basic usage of a random number generator is something like this:

  1. Seed (initialize) the random number generator
  2. Generate a random number
  3. Modulo the random number against your maximum number to get a number from 0 to your maximum number – 1.

Alright, first off I looked for Objective-C libraries. You know, maybe there was an NSRandom or something like that. There isn’t really one, so I went to look for C functions instead.

Digging into my memory banks, I remembered from my early C days that the standard C library call is srand() with a seed to initialize and then rand() to get the random number. So I looked up srand in the Apple Developer Connection (also known as ADC)
and came up with the laughable description:

rand, rand_r, srand, sranddev — bad random number generator

These interfaces are obsoleted by random(3).

Alright, so onto random. I looked up random in the ADC to see its Mac OS X Manual page. Alright, so it can generate numbers from 0 to (2**31) – 1. You can seed it with srandom() – which could be useful because the same seed will generate the same sequence of random numbers – useful for replaying a game sequence. A better seeding is to use srandomdev() which creates a state array which can’t be guessed by attackers and effectively uses the /dev/random device.

OK that seemed pretty good, but I read on and found this intriguing line:

Applications requiring cryptographic quality randomness should use arc4random(3).

Alright, so now I look up arc4random on ADC. arc4random uses the Alleged RC4 cipher, hence the ARC4. It has a range of 0 to (2**32 – 1), which is twice the range of random. It uses the /dev/urandom device. And best of all, in my opinion, it doesn’t require seeding/initializing since it initializes itself.

So the winner in my book for generating random numbers in Cocoa (really any Objective-C or C program on Mac OS X) is arc4random.

NSCoderNight tonight in Northern Virginia

I’ve been going to the past few NSCoderNights here in Northern Virginia. We’ve met up at Panera in Tysons before (look for the Apple logos.) But tonight we’re trying a different venue: Camille’s Sidewalk Cafe near the Courthouse Metro in Clarendon, VA. More details in Jose’s blog entry Trying a new location tonite.

It’s been pretty motivating to meet up with other Cocoa Mac and iPhone developers. I think we’re going to be discussing Cocoa Programming with Mac OS X by Aaron Hillegass soon, working our way through the chapters. I was privileged to have the experience of doing technical review on that book and I’ll have a full review of it on this blog soon. Short review: if you have the 1st or 2nd edition, it will help you get caught up to the newer Cocoa APIs and so its worth getting. If you don’t, then you definitely need this book to help you with your Cocoa programming. Big Nerd Ranch uses it as a text book for their Cocoa Bootcamps!

Cocoa / Washington DC Trivia: Aaron Hillegass grew up in Northern Virginia. We actually attended the same high school, Thomas Jefferson High School for Science and Technology, though at different times.

What to do before you do Ruby on Rails development on Mac OS X Leopard

Apple has a new series about Ruby on Rails development on Mac OS X Leopard. Its a nice article to help get you going. One thing I’d like to reiterate is that it is good to lock down your RubyGems paths. This way you will always that your RubyGems go in the right directories that Apple has set up.

So before you follow the steps in the initial Developing Rails Applications on Mac OS X Leopard article, you should take the following steps:

  1. Open up ~/.bash_profile in your favorite editor (create it if its not already there)
  2. Type in
    export GEM_HOME=/Library/Ruby/Gems/1.8
  3. Type in
    export GEM_PATH=/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
  4. Save ~/.bash_profile
  5. Execute
    source ~/.bash_profile

This makes it so that no matter what version of rubygems you have, you have access to the Apple-provided gems in $GEM_PATH and you’re able to install/update new gems in $GEM_HOME.

rcov 0.8.1 fixes Safari 3 colorization

Happy Thanksgiving everyone! I hope you enjoyed time with your family and friends.

Well one new thing that you can be thankful for is rcov 0.8.1. This new version of rcov fixes the colorization problem with Safari 3, which by the way now affects Ruby programmers on 10.4.11, not just those of us on Leopard 10.5.0 – 10.5.1. Note that the WebKit team is hard at work fixing the old underlying problem. It does pay to report bugs.

Anyways, enjoy the new rcov and your turkey leftovers. The easiest way to get it if you already have rcov is to do:

sudo gem update rcov

or if you don’t already have it:

sudo gem install rcov

Related posts:

Rcov

Ruby bugs on Leopard