Category Archives: Macintosh

Detective update

Twitter recently changed some of their rules for app authorization using OAuth, so as a result, when a new user tries to start Detective, they will get an error when authorizing Twitter. However, if you’re already using Detective it will continue to work as long as you don’t log out of Twitter.

Detective uses MGTwitterEngine, which no longer seems to be actively maintained and which still uses Twitter’s deprecated 1.0 API. As a result, at some point it would stop working when Twitter shuts off that API. I’ve looked into a few options and I’ve determined that the best way to move forward is to use Mac OS X’s built-in social framework. Rather than asking you to log in to Twitter, it will now use your Mac’s twitter accounts. However this means we will no longer be able to support any Mac OS X version earlier than 10.8. I hope to have an update available soon.

Detective Update

I’ve been working on an update to Detective which fixes some drawing problems in Mountain Lion and fixes a problem where it sometimes stops updating when the Mac wakes up from sleep.

Unfortunately it was rejected by Apple because of a sandboxing issue involving Growl. I haven’t been able to successfully set the entitlements for the auxiliary executable required by Growl, so I’m considering eliminating Growl, using Notification Center, and requiring Mountain Lion.

Sandboxing revisited

When I submitted an update to Detective, I discovered a few tricky things related to sandboxing and embedded helper apps.

In order to support ‘start at login’ in a sandboxed app, you need to embed a helper app that launches the main app (the entire process is described here). What I didn’t realize is that the helper app also has to be signed, or it will fail to let you start it at login. However, when you sign the helper app, it will include its own embedded provisioning profile, so when you try to submit your app, it will be rejected with the following message:

Invalid Provisioning Profile Location – The provisioning profile for your Mac OS X app must be located in the Contents directory of the main app bundle. A provisioning profile is optional, but you cannot submit more than one.

One of the suggestions in Apple’s developer forum is to remove the embedded profile from the helper app. Note that deleting the embedded profile doesn’t affect the actual code signing. After some experimentation, I found that the easiest way to do it is to add a Run Script build phase to the main application that deletes the profile from the helper app:

#!/bin/sh
rm ${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/Contents/Library/LoginItems/DetectiveLoginHelper.app/Contents/embedded.provisionprofile

After doing this, I was able to submit the app successfully.

Detective

Detective is a new Mac application that notifies you of new Twitter followers and people who unfollow you. It lives in the menu bar and posts Growl notifications.

Detective.png

Login items in the sandbox

Apple will soon require all Mac apps submitted to the app store to be sandboxed for heightened security, which means it needs to request permission for doing even basic things like accessing files or connecting to the internet. A lot of things like disk burning aren’t allowed at all in the sandbox, and some things like sending AppleEvents require temporary exemptions which will be phased out.

One common task that’s complicated by the sandbox is adding a login item. A good tutorial on creating login items is available at delite studio, although some changes to the code are needed. That code follows Apple’s earlier guideline of using LSRegisterURL to register your helper app. However, I found that it always fails with error -10819. According to an Apple engineer in Apple’s developer forum, you should not call LSRegisterURL in a sandboxed app.

Note that your application can’t add itself as a login item. You need to write a simple helper app that launches your main app and it must be included in the main application bundle in the relative path /Contents/Library/LoginItems/.

The method for adding & removing a login item turned out to be very simple:

- (void)addLoginItem {
    NSString *ref = @"com.madebynotion.myLoginHelper";
	if (!SMLoginItemSetEnabled((CFStringRef)ref, true)) {
		NSLog(@"SMLoginItemSetEnabled failed.");
	}
}

- (void)removeLoginItem {
    NSString *ref = @"com.madebynotion.myLoginHelper";
	if (!SMLoginItemSetEnabled((CFStringRef)ref, false)) {
		NSLog(@"SMLoginItemSetEnabled failed.");
	}
}

If you need to find out whether your login item is enabled, here’s a way to do it:

-(BOOL)appIsPresentInLoginItems
{
    NSString *bundleID = @"com.madebynotion.myLoginHelper";
    NSArray * jobDicts = nil;
    jobDicts = (NSArray *)SMCopyAllJobDictionaries( kSMDomainUserLaunchd );
    // Note: Sandbox issue when using SMJobCopyDictionary()
    
    if ( (jobDicts != nil) && [jobDicts count] > 0 ) {
        
        BOOL bOnDemand = NO;
        
        for ( NSDictionary * job in jobDicts ) {
            
            if ( [bundleID isEqualToString:[job objectForKey:@"Label"]] ) {
                bOnDemand = [[job objectForKey:@"OnDemand"] boolValue];
                break;
            } 
        }
        
        CFRelease((CFDictionaryRef)jobDicts); jobDicts = nil;
        return bOnDemand;
        
    } 
    return NO;
}

Although this method works and seems to be the preferred way to do it in the sandbox, it’s less optimal than the old non-sandbox method, since your login item won’t appear in the users & groups preference panel’s login items list and can only be turned on & off from your own application.

How far we’ve come

To see how far we’ve come since 1984, just compare the specs of the first Macintosh with today’s iPhone 4GS:

1984 Macintosh 128.png

We now carry in our pocket a device with a faster processor, more storage, and a higher resolution screen in a much smaller package than the computer we had sitting on our desk 27 years ago. Today’s Macintosh is many times faster, with a very different CPU, and has many times more storage, yet it’s still recognizable as a Macintosh and still has the same elegant simplicity.

R.I.P. Steve Jobs

Apple reports that Steve Jobs has died:

Apple has lost a visionary and creative genius, and the world has lost an amazing human being. Those of us who have been fortunate enough to know and work with Steve have lost a dear friend and an inspiring mentor. Steve leaves behind a company that only he could have built, and his spirit will forever be the foundation of Apple.

Apple’s home page is now a tribute to Steve Jobs.

Screen Shot 2011-10-05 at 8.06.19 PM.png

Steve Jobs truly changed the world. His influence has impacted the music & entertainment industries as much as in impacted the computer industry. The devices he created changed the way we listen to music, watch movies, and interact with our phones.

Sync OmniFocus with your own server

OmniFocus provides several ways to sync your data between devices, including MobileMe and their beta Omni Sync Server. If you have a web hosting account (such as DreamHost) that supports WebDAV, you can set up your own sync server without having to subscribe to any other services. Here’s how I set it up on DreamHost.

1. On your web host, set up a WebDAV directory. On DreamHost, go to Goodies -> Htaccess/WebDAV and choose a fully hosted domain. In the next screen, enter the name of a directory you want to use for WebDAV and password protect it.

Screen Shot 2011-09-08 at 8.52.37 PM.png

2. In OmniFocus on your Mac, go to Sync settings and switch to the advanced tab. Enter the name of a subfolder inside the directory you specified in step 1.

Screen Shot 2011-09-08 at 8.49.34 PM.png

3. Enter that same path on all of your mobile devices that you want to sync with it.

I find it to be much faster than MobileMe using my DreamHost server. Your results may vary depending on your web host or server.

Lion taught us we were scrolling the wrong way for 25 years

When I started using Lion, the first thing I did was turn off ‘Natural Scrolling’. A week ago, I decided to try natural scrolling again. After using it for a few days, I started getting used to it, and a week later, I actually find it more natural.

The way scrolling worked in the past, you were manipulating the scroll bar, which acted as a window into your document, showing the portion of your document that’s visible in the window. Therefore, when the scroll indicator is at the top you see the beginning of the document. When you drag it down to the bottom, you see the end of the document.

With natural scrolling, you’re manipulating the document content rather than the scroll bar. This is the same way scrolling works in iOS. Since Lion de-emphasizes the scroll bar, this makes more sense. I still prefer to show the scrollbar as an indication of the document size, however.

WWDC Wrap-up

I haven’t had a chance to write any blog posts last week while I was at WWDC, but I had a great time and learned a lot. This may have been the most important WWDC in recent years.

While last year’s WWDC focused primarily on iOS, this year’s conference was about equally split between iOS 5 and Mac OS X Lion. Both systems share some major enhancements including iCloud storage and Objective C runtime improvements that make memory management easier and a lot faster. I can’t write about much of what I saw, since everything except the keynote is under NDA. I will say that I’m running iOS 5 on my iPad and Lion on my MacBook Air and I’m very happy with both and find them stable enough for regular use. I haven’t installed iOS 5 on my iPhone, though.

On Sunday I went on the annual bus Pilgrimage to Apple’s headquarters in Cupertino. As always, the only thing we were able to see was the Apple company store. I took advantage of it to pick up a USB Ethernet adapter for my MacBook Air, since large downloads aren’t allowed over wireless connections during WWDC. I was pleasantly surprised by how fast the MacBook Air USB adapter is and how it just works without any fuss, unlike USB ethernet adapters I’ve used in the past.

1 Infinite Loop

WWDC isn’t all work. There are also a few fun events, starting with Tuesday night’s Apple Design Awards and Stump The Experts. One highlight of the conference is always the Thursday night WWDC Bash. Since the Bash moved from Apple’s campus in previous years to Yerba Buena Garden across from Moscone Center, Apple has been getting major bands to perform at the Bash. In previous years they had Ozomotli, Barenaked Ladies, Cake, and OK Go. This year they got Michael Franti & Spearhead for a great show.

The conference ended at noon on Friday, so I took advantage of the rest of the day to enjoy San Francisco. I walked from Moscone to the Ferry Building & took lots of pictures, which you can see here. I only brought my Canon G12, since I didn’t feel like lugging the D90. I’m very happy with the results, both for still photos & videos.