Archive for the 'Apple' Category

Random function-key changes

Wednesday, August 8th, 2007

Previous assignment of function keys:

KeyFunction
F9All windows
F10This application's windows
F11Reveal Desktop
F12Dashboard and Eject

This made (some) sense as the explanation for iLife 2008's refusal to allow you to assign these keys to its functions.

New assignment of function keys on otherwise-yummy new keyboards (yes, both of them):

KeyFunction
F1Decrease screen brightness
F2Raise it
F3Exposé (probably all windows), though it looks like it could just as easily summon a gallery app or iWeb or Stickies
F4Dashboard, though Activity Monitor would be a reasonable definition for this key's icon as well
F7Previous track
F8Playpause*
F9Next track
F10Toggle mute
F11Decrease volume
F12Raise volume
Eject

WTF?

* As named in iTunes' AppleScript dictionary.

Gun-jumping Apple Bug Friday! 67

Thursday, August 2nd, 2007

This bug is iTunes viewport pinned to top of selection when selection is at top of viewport. It was filed on 2007-08-02 at 10:31 PDT.

(more...)

WWDC 2007 session videos are out

Monday, July 30th, 2007

If you attended WWDC, you can head over to ADC on iTunes and see what you missed.

270,000 iPhones sold in first two days—not

Wednesday, July 25th, 2007

UPDATE 17:05 PDT: My theories have been disproven by my sharp commenters. See the comments for the true explanation. Thanks, guys!

Quoth the DFLL:

Apple Reports Third Quarter Results 

270,000 iPhones sold in the first two days, and Jobs is quoted in the PR saying “we hope to sell our one-millionth iPhone by the end of its first full quarter of sales”.

Incorrect.

Here's what Apple's unaudited summary data (linked from that press release) says:

Q2 2007Q3 2006Q3 2007
Units KRev $MUnits KRev $MUnits KRev $M
iPhone and Related Products and Services (6)----2705

So they sold 270,000 of “iPhone and Related Products and Services”. Suppose that all of those are $499 (which we know is false):

499 × 270,000 = 134,730,000

$134M! That's a long way from $5M.

The explanation is in that footnote 6:

(6) Consists of iPhones and Apple-branded and third-party iPhone accessories.

So if you bought an iPhone and a case, you effectively bought two iPhones for the purpose of that column. More accurately, you bought an iPhone (+1) and a Related Product (+1), for a total of +2.

I suspect the real number of iPhones, not counting accessories, is much, much closer to AT&T's 146,000-activations number (since very few people will buy an iPhone and not activate it).

Code signing: Not as new as you think

Tuesday, July 3rd, 2007

Code signing is new in Leopard, right?

Right?

No, actually; it's much older, as I found out while responding to a question on programming.reddit. In my results for a Google search that I did, I stumbled over a link to TN1176, which mentions the addition of code signing.

TN1176 is the release notes for Mac OS 9.

The technote doesn't actually say much. In fact, I can go ahead and quote it in full:

Apple Code Signing is a new technology in Mac OS 9 that allows applications, plug-ins, and content to be signed by developers. Apple Code Signing Certificates assure your customers of your identity and the integrity of your products. For more information, please see the Mac OS Security and Cryptography Web site.

That site's gone now, of course. Fortunately, the Wayback Machine saved a copy.

Screenshot of the icon for
Apple Verifier

Screenshot of the icon for
Apple Signer

The top link on that page is to the Security 2.0 SDK, which includes a lot of stuff relating to code signing. There's a pair of utilities called Apple Signer and Apple Verifier, some API documentation, some sample code, some resource templates (remember those?), a library, and the debugging root certificate.

UPDATE 06:29: Apple Verifier actually comes with the OS, but Apple Signer is only available in the SDK.

If you've ever seen a 'sign' resource while hacking in ResEdit, now you know what it was.

Meet the new boss
Same as the old boss


Oh, and in case you're wondering what the Signer and Verifier applications look like:

This screenshot shows Apple Signer generating a signature for the SDK archive.
Signer at work.

This screenshot shows Apple Signer verifying the same signature.
Signer can also verify.

This screenshot shows the result of Apple Signer's verification of the signature.
Result of verification.

This is a screenshot of the Apple Signer window that shows the contents of a certificate.Same window, but for a root certificate.
These are the certificates from the verification. The root cert is the “Issuer's Certificate” for the other one.

This screenshot is of a dialog box that says “That application or control panel is not supported by Classic”.
This is why I didn't explain the difference between Apple Signer's Verify command and Apple Verifier: I don't know, because this message comes up when I try to launch Apple Verifier. And no, I don't know why the message comes up.

Apple Bug Friday! 63

Friday, June 22nd, 2007

This bug is hdiutil provides no facility to change bzip2 block-size. It was filed on 2007-05-25 at 13:49 PDT.

(more...)

Apple Bug Friday! 62

Friday, June 22nd, 2007

This bug is User 501 gets the admin bit after migration. It was filed on 2007-05-25 at 13:29 PDT.

(more...)

The well-hidden documentation of Core Audio

Sunday, June 17th, 2007

Ordinarily, I'd post this on del.icio.us, but this isn't on developer.apple.com and I don't think del.icio.us allows file: URLs.

Most use of Core Audio goes through Audio Units, but the Audio Unit API has historically been undocumented. Today, I finally found the Audio Unit documentation. Turns out that, rather than being in the /Developer/ADC\ Reference\ Library/Documentation folder (where you would expect documentation to be), it's hidden in the /Developer/Examples folder. This documentation is so good (damn near production-quality) that I feel like I've struck a rich vein of gold ore.

WTF, Apple?

People I’ve met at WWDC

Thursday, June 14th, 2007

This is a partial list until Friday night, but it's worth posting now because of all the people I met at the WWDC Bash.

Where possible, I've also listed their IRC nickname.

Adium-related people I met at WWDC

Other people I met at WWDC

  • Karl Adam (PantherMachina)
  • Dave Batton [Added Friday, though I met him before the Keynote]
  • Ken Ferry (kongtomorrow)
  • Andy Kim [Added Friday]
  • Paul Kim (mr_noodle) [Added Friday, though I met him after the Keynote]
  • Devin Lane (DevG5)
  • Gus Mueller (ccgus) [Added Friday]
  • Scott Stevenson [Added Friday; I'd met him previously at CocoaHeads]
  • Many Adium fans (thanks for your kind words, everyone!)

Bloggers I met at the WWDC Bash

Bloggers I met at CocoaHeads

The audience was SRO, so David and I (along with Devin and Michael Gorbach) just went off to The Studio and hacked code. After the meeting, I went up to Scott, and we shook hands and that was it. My guess is that it was a busy night and he wanted sleep.

People I've seen at WWDC, but did not talk to

People I saw at the WWDC Bash, but did not talk to

  • john calhoun
  • Martin Ott (I think he saw my Adium shirt and said “look, Adium!”, but it could just be wishful hearing, considering Ozomatli was blaring at the time)
  • Some other people I'm totally blanking on

iTunes is now available without DRM

Wednesday, May 30th, 2007

They're calling it “iTunes Plus”, and the current Single-of-the-Week is available in it. Took them long enough—yesterday was the last Tuesday in May, and they didn't even get done with it until today.

Ah, well. At least it's finally here. Woo-hoo!

By the way, you need to update to iTunes 7.2 and agree to the iTS terms and conditions again to turn on iTunes Plus. The actual T&C haven't changed, but the Terms of Sale have.

I’d forgotten how awesome Sherlock is

Sunday, May 27th, 2007

Compare this translation interface (what I've been using):

Babel Fish, with its small input textarea,
Babel Fish (in Camino, because none of my other browsers work with it)

to this one (what I should be using):

Sherlock, with its text fields that take up almost the entire window.

I used to hate Sherlock under Mac OS 9—I went so far as to custom-install Find File from Mac OS 8.5. But Sherlock under Mac OS X is pure awesome.

Now, if they kill it in a future OS version, I'll be sad. And I may end up cherry-picking from the old OS disc again.

Virtual key-codes

Tuesday, May 22nd, 2007

Anybody who's ever needed to work with virtual key-codes—especially to program a hotkey—has had the problem of looking up the key-code for a specific key. The usual solution is to fire up Peter Maurer's Key Codes.app and press the key, but wouldn't it be nice to look it up in a handy table that you could print out?

There actually is such a table, but it's well-hidden in the Apple documentation. Mac OS X uses the same virtual key-codes that it used for the legendary Apple Extended Keyboard. Thus, the table in Inside Macintosh: Text still applies.

The problem is the asstastic low-resolution JPEG scan of the table that Apple provides in the online version of IM:Tx:

Good luck with that!

So I did some poking. It turns out that there is a PDF version of IM:Tx on the ADC website—complete with a vector, rather than raster, table. Unfortunately, opening a PDF and jumping to figure C-2 is no easier than firing up Key Codes and pressing the key.

So here's a handy-dandy PNG version of the key-codes table, cropped straight from the PDF. It's 600 dpi, so you should be able to print it out on any printer without a problem (and if not, you're welcome to do the same crop procedure yourself). Here's what it looks like:

In case you're wondering, I cropped it by copying the figure in Preview, then pasting into Lineform, which allows me to export to PNG at 600dpi rather than 72.

Disk images suck: An examination of why, and of the alternatives

Sunday, May 13th, 2007

Here is a rundown of every file format you can use to distribute your software, along with their advantages and disadvantages. They are listed in ascending order of effectiveness.

In case you're wondering, 7-zip and StuffIt X are not listed here because nobody has decompressors for them. I wrote this list for the context of software distribution; the days of saying “You will need StuffIt Expander to open this file” are long over.

Disk image

Advantage:

Sandboxes the application: If it won't work from the disk image, it probably sucks

Disadvantage:

Confuses the average user; they typically run the application from the disk image, then encounter problems when they try to delete the image file or (much later) run a Sparkle update


Back in March, an Adium user had a problem trying to perform the Sparkle update. It gave her an error:

“Update Error! Adium does not have permission to write to the application's directory! Are you running off a disk image? If not, ask your system administrator for help.”

This wouldn't be so bad, except that she didn't know what a disk image was, so she assumed that she was not running Adium from the disk image (I imagine she thought something like “surely I'd know what that was if I was using one”). She looked up the troubleshooting instructions in the Adium help (good), then critically misunderstood them (bad) with the result that she moved her Adium 2.0 folder out of the Application Support folder. (Don't ask me to explain it. I don't know, either.)

All this ultimately resulted from the fact that average users, including her, don't recognize a disk image when they see it. They don't expect a file to act as a drive.

The same non-obvious nature results in other problems: specifically, the error message “The operation cannot be completed because ‘SurfWriter-1.0.dmg’ is in use”. This occurs when the user tries to delete the disk image file without unmounting it first. Users who encounter this message end up contacting us (usually asking “how do i uninstall it”). This is only natural, because who would expect that a file is mounted, or that a file can be in use in another file?

It was then that I realized that disk images are not as great for the average user as I had previously believed.

You may be thinking “well, just put a background image with an arrow to an Applications folder”. We did that. It didn't help this user.

The stories I heard from other developers suggest that people in general zero in on the application they want to use, without paying attention to anything else (e.g., arrows, help text, or symlinks). Besides, the questions I hear from the users via the feedback list suggest that users see the disk image window and think the application is already installed—they aren't looking for or expecting installation instructions, so your big arrow means nothing to them.

I suspect that installers are partly to blame for that: I don't know about Windows, but on Mac OS, installers would always open the folder containing the freshly-installed application, so that you could use it right away. I suspect that users mistake the disk image window for a freshly-installed-folder window.

Anyway, one solution to the tunnel-vision problem would be a “DRAG THIS OVER HERE” message in a big font—but that's no good, because you can't have localized background images. You'd have to pick one language, and hope that all your users know it, but anybody who doesn't know the language you chose wouldn't benefit from your nice obnoxiously big text. (On the other hand, this provides a second reason for unilingual builds: One disk image per language, with both the background and the application localized in that language only. Hmmmm.)

Another solution is a runtime check whether the app is running from the disk image. You'll have to be careful with wording here, though—you need to be 100% sure that you're running from a disk image, and write the alert text accordingly. There can be no vacillation like in the Adium alert box (which vacillates because it's caused by a simple permission failure, not an actual search for the disk image nature); it must be a statement, not a question. And of course, you must tell the user the remedy (copy the app, then run the copy, then eject the disk image file and never mount it again).

One last point: bzip2 compression (-format UDBZ) requires Tiger. Your disk image won't mount on any earlier version of the operating system; your users will think it's corrupt, since that's what the error message suggests, and they'll contact you with that assumption. This probably doesn't matter anymore, since the Omni Group's software-update statistics say that 98.4% of users are on Tiger (as of 2007-05-12), but if you still support users of earlier OS versions, you need to use zlib compression (-format UDZO) instead.

Tarball

Advantages:

Smaller than disk images; unpacks into a folder or bare application

Disadvantage:

Safari mishandles bzip2'd tarballs pretty spectacularly; one must gzip one's tarballs to avoid that problem, but then one loses out on yummy bzip compression


Safari, for some reason, saves a bzip2'd tarball as “foo.tbz.tar”, even though it is still a tbz. Unpacking it results in a tar archive named “foo.tbz”, followed by the folder that the tar archive exists to hold. So the actual unpacking behavior works as expected, but it badly screws up the filenames.

This all works correctly with tgz, but of course you can't use gzip and have bzip2 compression.

Zip archive

Advantages:

Unpacks into a folder or bare application; can be created from the Finder

Disadvantage:

Bigger than anything else


Zip archives are the easiest to create, because you can simply right-click on the contents and choose “Create Archive of SurfWriter.app”. Unfortunately, the compression ratio is just not there; I consider zip files obsolete for this reason. You should be optimizing for your users' download time, not your own compression time.

Internet-enabled disk image

Advantage:

Unpacks into a folder or bare application for the average user (Safari with “Open Safe Files” turned on); perfectly normal for everybody else

Disadvantages:

Won't work the same way twice (when the user goes to unpack it the second time, it behaves as a perfectly normal disk image, with the attendant confusing UI); hard to create; unpacks slowly


This is the best of both worlds. The average user uses Safari and has “Open Safe Files” turned on; in this case, Safari will unpack the disk image just as if it were a tarball or zip archive. The sort of person who turns “Open Safe Files” off, or uses a different browser, is also the sort of person who can handle a normal disk image, and will indeed be handling it because that's how the disk image behaves in those cases. The extremely-rare exceptions can be handled by the aforementioned runtime check.

They're the hardest to create because you need to use a Terminal command (hdiutil internet-enable SurfWriter-1.0.dmg) to set the internet-enabled bit on the image. Dear Lazyweb: Please make a contextual menu item that generates an internet-enabled UDBZ disk image directly from a folder in one step, the same way I can make a zip archive in one step. (Michael Tsai, in a comment, says that his $20 DropDMG utility can do this, with Automator's help.)

Another disadvantage is that a disk image, internet-enabled or otherwise, takes much longer to process than a zip archive. I think this is because of the verification step, but the user won't care. I think people will put up with it for most archives, but if your archive is huge (let's say over 50 MiB), you may want to switch to a zip or tarball to save time. Of course, you'll be sacrificing part of your bandwidth bill for that. (Thanks to Sven-S. Porst for bringing this up in another comment.)

Also, the format notes (UDBZ vs UDZO) for disk image above apply to internet-enabled disk images as well. Just in case you were wondering.

I bring this up because, having in mind my objections above to disk images, I released EasyMD5 as a zip archive. I did it this way because EasyMD5 is targeted at Adium users (specifically, those who have problems downloading Adium); experience has proven that I can't assume that an Adium user will know how to deal with disk images. Everybody knows how to handle zip archives (hello, Chris!), so I made it a zip archive.

I hadn't yet done the study of file sizes that I did and published yesterday. Now that I have, later today, I'll replace the zip archive with an internet-enabled disk image.

UPDATE 11:37: Added mentions of Paul Kim's proposal of a runtime check for the disk image nature, and clarified the Lazyweb request.

UPDATE 20:47: Updated to include comments from Sven-S. Porst and Michael Tsai.

Just in case you missed the WWDC early registration period…

Tuesday, May 1st, 2007

…you didn't.

Apple has extended the WWDC early registration deadline to May 11.

How do I swap thy bytes? Let me count the ways

Saturday, April 28th, 2007
  1. swab

    swab(3) is a function that copies some bytes from one location to another, swapping each pair of bytes during the copy. Handy for structures.

    It has a feature that isn't mentioned in the Darwin manpage for swab: If you pass a negative size, it does not swap. I have no idea why this magic behavior was added; if you want a swab that doesn't swap bytes, just use bcopy. I shake my head at this use of a magic argument.

  2. ntohs, htons, ntohl, htonl

    These four functions swap the bytes of a 16-bit (‘s’) or 32-bit (‘l’, in ignorance of LP64) integer and return the transformed value.

    They are mainly used in network-I/O contexts, as they transform between network byte order (big-endian) and host byte order (whatever you're running). But there's nothing stopping you from using them for any other 16-bit/32-bit integral byte-swapping.

  3. OSByteOrder (Darwin)

    The Darwin kernel provides a number of handy-dandy macros for byte-swapping:

    • OSSwap{Const}?Int{16,32,64}
    • OSSwap{Host,Big,Little}To{Host,Big,Little}{Const}?Int{16,32,64}

    The {Host,Big,Little}To{Host,Big,Little} functions swap conditionally; the others always swap.

    According to the Universal Binary Programming Guidelines, it is safe to use these in applications.

  4. Core Foundation

    CF's Byte-Order Utilities provide the same facilities as OSByteOrder, with a couple of twists:

    • The implementation uses assembly language when the environment is GCC on either PowerPC or x86. This is theoretically faster than OSByteOrder's pure-C implementation. (CF falls back on pure C in all other environments.)
    • CF adds support for byte-swapping 32-bit and 64-bit floating-point numbers.
  5. Foundation

    Foundation's byte-order functions bear all the same capabilities as the CF Byte-Order Utilities. In fact, they are implemented with them.

  6. NeXT byte-order utilities

    These utilities are equivalent to the Foundation functions, except that they are implemented using the OSByteOrder utilities. They are declared in <architecture/byte_order.h>.

  7. Core Endian

    Core Endian logo that I made up.

    I think that the “Core Endian” name itself is new in Panther. Three functions in the API have a “CoreEndian” prefix, and are marked as new in Panther, whereas the others have simply “Endian”, and are marked as having existed since 10.0. This suggests to me that the entire API was branded “Core Endian” in 10.3, with the older functions subsumed by it.

    The new functions have to do with “flipper” callbacks, which you can install so that things like Apple Event Manager can DTRT with your custom data types. The older functions are plain byte-swapping utilities, just like all the other APIs described here, and exist mainly for the benefit of QuickTime users (they exist on Windows, too, through QuickTime).

Apple Bug Friday! 56

Saturday, April 21st, 2007

This bug is iTunes does not FNNotify after moving items to the Trash. It was filed on 2007-04-13 at 19:56 PDT.

(more...)

Wit and wisdom from the manpages

Tuesday, April 17th, 2007

From man strftime:

BUGS

There is no conversion specification for the phase of the moon.

Feel free to share your favorite manpage jokes in the comments. (I'll do one for you: the obligatory tunefs joke.)

ICeCoffEE and Services are your friends

Thursday, April 12th, 2007

ICeCoffEE is an APE extension by Nicholas Riley that lets you ⌘-click on a URL in any NSTextView to open that URL in your favorite browser.

But it has another feature that's far more useful than that.

ICeCoffEE is named after ICeTEe, an extension for Mac OS that also provided the ⌘-click feature. ICeTEe added it to TextEdit (that's the “TE” part; TextEdit was the text-editing control in Mac OS, and it's totally separate from TextEdit.app). But ICeCoffEE has one other feature, which I find far more useful. It's a two-part feature:

  1. It adds a Services menu to your contextual menu.
  2. And you can edit that menu.

What that means is that rather than having to mouse all the way up to the Application menu, then rifle through an enormous list of services*, you can instead simply right-click on the view that already has your focus, and find the service you want among the set of services that you actually use.

(Before you mention ServiceScrubber: That works by editing applications' Info.plists. Not a good way to go about it. I'd rather have services specifically excluded from the Services menu without having to edit any part of the applications. ICeCoffEE provides this.)

This is pretty big. The major reason why people don't use services—even in the face of ThisService, which is the greatest developer tool since Interface Builder—is having to cross half the screen and then wade through several dozen menu items. ICeCoffEE solves both of those problems, so now you have no excuse not to use the full power of services in your work.

It also lets you put the Services menu in the menu bar, but while that beats having it hidden in the Application menu, I don't think that that's as cool as having it in the contextual menu. Worse, it doesn't let you edit the menu-bar Services menu. The one in the contextual menu is a hundred times more useful.

ICeCoffEE is free and a UB, and works in any Cocoa app. You'll need Mac OS X 10.1 or later, though current versions require 10.3.9 or later.

* My Services menu has 46 menu items in it, and that's counting submenus as 1 each.

A novel way to reduce the size of a grayscale PNG file

Sunday, April 8th, 2007

Today, I scanned in one of my old drawings: a study of five-pointed stars that I made when I was trying to figure out how to draw a proper star (this was at the time of me working on Keynote Bingo MWSF2007 Edition, and a derivative of the same star is used in TuneTagger).

The odd thing is, after I corrected the image using Preview's Black Point and Aperture controls (no relation to the photo-management program), the image weighed about two-fifths as much:

du -b Five-pointed\ star\ study* %~/Pictures(0) 1403443 Five-pointed star study-adjusted levels.png 3346498 Five-pointed star study.png

(These sizes are after pngout, but even if I re-correct the original image and save it elsewhere, it comes out 1790244 bytes long.)

Go figure.

Report-an-Apple-Bug Friday! 54

Friday, April 6th, 2007

This bug is iTunes should use real combo boxes in its Info dialogs. It was filed on 2007-04-06 at 23:48 PDT.

(more...)