A vim quickie
Saturday, July 22nd, 2006:g/^[-+].\+{\s*$/,/^}/fold ←Folds all Obj-C methods in the current file.
Technorati tags: vim
:g/^[-+].\+{\s*$/,/^}/fold ←Folds all Obj-C methods in the current file.
Technorati tags: vim
This bug is Can't drag-and-drop to “Title” field on PackageMaker's Interface tab. It was filed on 2006-05-19 at 02:38 PDT.
The “Title” field on the “Installer Interface” tab is not a drop target.
The cursor changes to the Copy cursor, and when the mouse button is released, the text is inserted at the drag destination insertion point.
The cursor does not change, and when the mouse button is released, the drag snaps back.
None known.
None.
Technorati tags: Apple Bug Friday, applebugfriday
This bug is PackageMaker's keyboard shortcuts are not consistent with Xcode's. It was filed on 2006-05-19 at 02:28 PDT.
The list in the Notes section is adapted from another blog post of mine, Know your Xcode.
PackageMaker's keyboard shortcuts for Build, Build Log, Run, and Run Log do not match up with Xcode's shortcuts for the same commands.
The Build Log appears.
*Beep*
None known.
Xcode has a simple and elegant system for its keyboard shortcuts:
PackageMaker should adopt the same schema, both for its elegance and for uniformity with Xcode.
Technorati tags: Apple Bug Friday, applebugfriday
I just discovered this — you can use the numeric keypad to move views in a nib. The benefit of this is that you can perform atomic diagonal moves (as opposed to a rapid sequence of, for example, up followed by left).
Technorati tags: Interface Builder
I've been working on a header search tool in Python. You run the index tool, and it creates the database (using PostgreSQL and PyGreSQL); then you can use the search tool to look up headers either by name or by keyword:
python searchheaders.py name=NSAffineTransform.h %~/Python/sql_headersearch(0) NSAffineTransform.h /System/Library/Frameworks/AppKit.framework/Headers/NSAffineTransform.h NSAffineTransform.h /System/Library/Frameworks/Foundation.framework/Headers/NSAffineTransform.h ___ python searchheaders.py symbol=NSAffineTransform %~/Python/sql_headersearch(0) NSAffineTransform "/System/Library/Frameworks/AppKit.framework/Headers/NSFontDescriptor.h" NSAffineTransform "/System/Library/Frameworks/AppKit.framework/Headers/NSBezierPath.h" NSAffineTransform "/System/Library/Frameworks/AppKit.framework/Headers/NSAffineTransform.h" NSAffineTransform "/System/Library/Frameworks/AppKit.framework/Headers/NSFont.h" NSAffineTransform "/System/Library/Frameworks/Foundation.framework/Headers/NSAffineTransform.h"
It's not done yet, obviously (for one thing, I don't know why those quotes are in there), but it's coming along nicely. And it's quick, though not very:
time python searchheaders.py name=NSAffineTransform.h > /dev/null python searchheaders.py name=NSAffineTransform.h > /dev/null 0.06s user 0.10s system 44% cpu 0.371 total ___ time python searchheaders.py symbol=NSAffineTransform > /dev/null python searchheaders.py symbol=NSAffineTransform > /dev/null 0.06s user 0.10s system 6% cpu 2.339 total
I want to see if there's anything I can do to fix that query time. Probably something involving PostgreSQL's array types, so that I can make the keyword column a primary key.
This, incidentally, is why I needed to parse the preprocessor.
Technorati tags: Programming.
If you've ever run GCC's preprocessor alone and looked at its output, you've seen lines like these:
# 1 "/usr/include/sys/types.h" # 1 "<built-in>" # 1 "<command line>" # 1 "/usr/include/sys/types.h" # 66 "/usr/include/sys/types.h" # 1 "/usr/include/sys/appleapiopts.h" 1 3 4 # 67 "/usr/include/sys/types.h" 2 # 1 "/usr/include/sys/cdefs.h" 1 3 4 # 70 "/usr/include/sys/types.h" 2
And you probably wondered what all that means. Here's your secret decoder ring.
First, these are called "line markers" in libcpp. The format of a line marker is:
The flag values are:
extern "C" protection (determined by the same rules as above); never found without 3Note that a pop applies to the header above (in the include stack) the one referenced in the marker.
Example:
# 66 "/usr/include/sys/types.h" # 1 "/usr/include/sys/appleapiopts.h" 1 3 4 # 67 "/usr/include/sys/types.h" 2
#include <sys/appleapiopts.h>).The relevant code in libcpp is in directives.c. The function that parses line markers (presumably used by the compiler rather than the preprocessor itself; the preprocessor generates them) is do_linemarker. Additional include-related code is in files.c.
UPDATE 23:24 PDT: Beware of pragmas. Seems obvious now, but I didn't think of it earlier: The preprocessor leaves #pragma directives untouched, being that they're for the compiler rather than the preprocessor. So if you're only looking for line markers, you may get tripped up if you don't properly handle/ignore a pragma.
Technorati tags: GCC, cpp, C preprocessor.
This bug is PackageMaker (and Installer?) does not support EPS, PDF, or SVG in packages. It was filed on 2006-05-19 at 02:20 PDT.
PackageMaker/Installer should support the use of EPS, PDF, or SVG image files in Installer packages.
The EPS, PDF, or SVG file is accepted as the background of the package.
The EPS, PDF, or SVG file snaps back (drag), or is disabled in the list (choose file).
As far as I know, Installer has never supported EPS, PDF, or SVG files.
Vector graphics would scale cleanly to any resolution, which is good for the coming resolution-independent UI. Currently, it is necessary to use a large and/or multi-image TIFF file, and hope that it's enough.
Technorati tags: Apple Bug Friday, applebugfriday
This bug is PackageMaker (and Installer?) does not support PNGs in packages. It was filed on 2006-05-19 at 02:00 PDT.
PackageMaker/Installer should support the use of PNG image files in Installer packages.
The PNG file is accepted as the background of the package.
The PNG file snaps back (drag), or is disabled in the list (choose file).
As far as I know, Installer has never supported PNG files.
PNG supports compression, for smaller Installer packages. True, Installer packages are often distributed on compressed disk images or in compressed zip archives, but PNG can “filter” the image bytes to be more compressable, resulting in greater savings.
Technorati tags: Apple Bug Friday, applebugfriday
This bug is IB refuses to keep pop-up menus open. It was filed on 2006-05-12 at 02:33 PDT.
IB closes a pop-up menu being edited in response to any key or mouse event in the menu.
The current selected item changes, or is renamed, or both.
The current selected item changes, or is renamed, or both, and then IB closes the menu, interrupting any plans to further edit the menu until the menu is reopened by the user.
This used to work, although I don't know in what version.
No Console output is emitted by IB.
UPDATE 2006-05-24: I got an email from Apple recently telling me that the bug was a duplicate, and just today, Xcode 2.3 came out, including IB 2.5.4 which fixes this bug.
Technorati tags: Apple Bug Friday, applebugfriday
This bug is -mtune (Instruction Scheduling) does not include Intel processors. It was filed on 2006-04-28 at 00:35 PDT.
With the move to Intel processors, Xcode needs to support processor-specific optimization for them.
At least pentium-m is listed, being (presumably) the most similar to Yonah (the "Core Solo"/"Core Duo" processors). Ideally, scheduling optimizations for Yonah itself should be added to GCC, with a matching listing in Xcode's pop-up menu.
Only G3, G4, and G5 are listed (besides "None").
This wasn't a problem before the move to Intel.
Direct Yonah support isn't supported by GCC (yet) according to the GCC manual's page "i386 and x86-64 Options". GNU's current documentation doesn't list it either.
Technorati tags: Apple Bug Friday, applebugfriday
Like many, I use the popular open-source text editor vim. Earlier, I set about making it more usable through syntax coloring. This included tweaking its support for Objective-C.
First, mkdir ~/.vim, and cd ~/.vim. Now mkdir syntax. cp /usr/share/vim/vim62/filetype.vim . and cp /usr/share/vim/vim62/syntax/objc.vim syntax/. Then select and copy this patch:
Index: filetype.vim
===================================================================
--- filetype.vim 2005-03-21 02:12:47.000000000 -0800
+++ filetype.vim 2006-04-24 03:33:27.000000000 -0700
@@ -262,7 +262,7 @@
" .h files can be C or C++, set c_syntax_for_h if you want C
au BufNewFile,BufRead *.h
- \ if exists("c_syntax_for_h") | setf c | else | setf cpp | endif
+ \ if exists("c_syntax_for_h") | setf c | else | if exists("objc_syntax_for_h") | setf objc | else | setf cpp | endif | endif
" TLH files are C++ headers generated by Visual C++'s #import from typelibs
au BufNewFile,BufRead *.tlh setf cpp
Index: syntax/objc.vim
===================================================================
--- syntax/objc.vim 2005-03-21 02:12:49.000000000 -0800
+++ syntax/objc.vim 2006-04-24 03:19:25.000000000 -0700
@@ -43,6 +43,8 @@
syn match objcDirective "@class\|@end\|@defs"
syn match objcDirective "@encode\|@protocol\|@selector"
+syn keyword objcStorageClass in out inout byref bycopy
+
" Match the ObjC method types
"
" NOTE: here I match only the indicators, this looks
@@ -73,6 +75,7 @@
HiLink objcFactMethod Function
HiLink objcStatement Statement
HiLink objcDirective Statement
+ HiLink objcStorageClass StorageClass
delcommand HiLink
endif
Now type pbpaste | patch -p0.
OK, now you have modified copies of the file type detector and the Obj-C syntax coloring. Now you need a .vimrc. If you already have one, add this to it; otherwise, create it with this:
let c_gnu=1 let c_no_bracket_error=1 let objc_syntax_for_h=1 syntax enable
This makes the following changes:
{} inside of []. This lets you do compound literals inside messages; for example: [self setFrame:(NSRect){ NSZeroPoint, (NSSize){ 128.0f, 128.0f } }]; Technorati tags: vim, Objective-C.
This bug is Xcode: Use standard Xcode text view as field editor. It was filed on 2006-04-21 at 22:03 PDT.
Xcode's field editor should be an Xcode text view rather than a plain NSTextView, so that completion and ctrl-left/-right are supported.
The insertion point moves to within the class name.
Xcode/NSTextView beeps.
None.
None.
Technorati tags: Apple Bug Friday, applebugfriday.
This bug is Xcode: Cocoa Document-Based Application template uses old-style document methods. It was filed on 2006-04-21 at 21:19 PDT.
NSDocument documentation recommends using -readFromData:ofType:error: and -dataOfType:error:, but the project template uses the older methods.
MyDocument, from the new document, implements -readFromData:ofType:error: and -dataOfType:error:.
MyDocument implements the deprecated methods -loadDataRepresentation:ofType: and -dataRepresentationOfType:.
Prior to Mac OS X 10.4, this wasn't a problem, because -loadDataRepresentation:ofType: and -dataRepresentationOfType: were not deprecated.
One could make the argument that the deprecated methods should still be implemented so that the new application is compatible with 10.3.x and earlier. But a new application is not likely to require such compatibility. Also, if this argument is indeed the motivation, then the project should target the 10.3 (or an earlier) SDK.
Technorati tags: Apple Bug Friday, applebugfriday.
This bug is Interface Builder should use +/- buttons for Outlets and Actions lists. It was filed on 2006-04-21 at 21:06 PDT.
IB uses "Add" and "Remove" buttons on the Outlets and Actions lists; it should use +/- instead, like the Accounts prefpane.
IB shows small square buttons labeled + and - like the Accounts prefpane has.
IB shows plain "Add" and "Remove" push buttons.
None.
None.
Technorati tags: Apple Bug Friday, applebugfriday.
This bug is ⌘W and ⌘⌥W close Inspectors too. It was filed on 2006-04-14 at 23:45 PDT.
When the user presses ⌘W, IB will close a floating window if it has focus. When the user presses ⌘⌥W to close all nib windows, IB also closes all of the floating windows.
The frontmost non-floating window closes, or all non-floating windows and no floating windows close.
The frontmost window (floating or not) closes, or all windows (including floating windows) close.
None known.
Floating windows in IB are the Palette, the Alignment palette, and the Inspector.
Technorati tags: Apple Bug Friday, applebugfriday.
A couple of tips for using Xcode more efficiently.
Most commands that start an operation stop it as well. ⌘B, for example, starts and stops a build. ⌘⌥R will terminate a running subprocess.
Rule of key commands: With ⌘ and no other modifiers, the key command does at least a build. ⌘⌥ will do that thing alone, without building first. ⇧⌘ opens the progress window for that operation, without actually doing it. This applies to:
Any other suggestions? Please post them in the comments.
Technorati tags: Xcode.
This bug is Xcode's Condensed layout does not have scrollers. It was filed on 2006-04-07 at 23:42 PDT.
The Condensed layout for Xcode's project window does not have scrollers.
The window has or gains scrollers.
No scrollers.
The Default/Detail view, which is the only layout in all Mac OS X versions of Project Builder and the pre-Condensed versions of Xcode and the default in versions that do have Condensed, does not have this problem.
The All-in-One layout does not have this problem either.
The window can be scrolled using a scroll wheel or scroll-capable trackpad, or software such as Catchy Software's MaxiMice. The window can also be indirectly scrolled by using the arrow keys to select the next item up/down.
Technorati tags: Apple Bug Friday, applebugfriday, Xcode.
UPDATE 2008-07-15: You no longer need to do this as of Xcode 3.1. Make sure you fill out your Address Book. (If you don't want to use the company name on your Address Book “Me” card, then you do need to follow these instructions.) Thanks to BJ Homer for pointing this out in his comment.
Xcode comes with a number of document templates. You see the list of them when you choose File→New Document in Xcode. The templates are actually stored at /Library/Application Support/Apple/Developer Tools/File Templates. Most files contain a header comment that looks like this:
/* * «FILENAME» * «PROJECTNAME» * * Created by «FULLUSERNAME» on «DATE». * Copyright «YEAR» «ORGANIZATIONNAME». All rights reserved. * */
The problem is ORGANIZATIONNAME. This gets replaced with “__MyCompanyName__”, and there is no obvious way to change this other than by changing it every time (or by editing the templates, a solution that gets clobbered when you upgrade Xcode).
I was reading Step into Xcode, and found that on page 53, it gives instructions for defeating __MyCompanyName__. Here's the important part, from the book:
defaults write com.apple.xcode PBXCustomTemplateMacroDefinitions '{ ORGANIZATIONNAME = "Joan Smith"; }'
This information is also available on this Xcode release notes page. It's slightly inaccurate (__CompanyName__ rather than __MyCompanyName__) and well-buried, but it documents the same thing as the book.
Presumably, you could override any macro name or add your own using that default. But ORGANIZATIONNAME is the important one.
I debated about posting this here (publicly, rather than only privately to the Adium and Growl developer lists), because I got the info from the book. But I decided that it's OK because (1) it is also documented by Apple and (2) it's an example of the good info in this book. So here it is.
UPDATE 2007-04-07: Markus Magnuson sagely points out that you must relaunch Xcode after making this change. This really applies to any application whose prefs you plan on hand-modifying; Xcode is no exception. Thanks for the reminder. ☺
fie on Blogger. this post isn't visible from the front page or the Dashboard, even though it exists. so I'm reposting it.
UPDATE 2006-02-25: it has been closed as a duplicate.
C99 escapes in Obj-C string contain UTF-8 interpreted as an 8-bit encoding. as last time, edited only for HTMLification.
since C99, C has a \u escape for Unicode characters. for example, a snowman is \u2603.
when used in an Obj-C string literal (@"foo"), however, these escapes are broken.
the Unicode character is displayed as such.
the Unicode character's UTF-8 representation is displayed in some 8-bit encoding (possibly ISO 8859-1).
none known.
the bug only occurs in Obj-C string literals, not plain C string literals.
it appears that the compiler uses UTF-8 for internal storage, which works. NSConstantString, however, seems to expect ISO 8859-1, and interpret its input as such.
the enclosed tarball contains test programs (command-line) in plain C (using printf) and Obj-C (using NSLog). the plain C version works; the Obj-C does not.
I found the bug when displaying an Obj-C constant string (which had been passed through NSLocalizedString, but there is no matching localisation for it yet) as an NSMenuItem's title. so the problem is not specific to terminals or Terminal's display, nor dependent on the value of any locale environment variables.
I also attached two test cases.
Recently, I went to Apple’s games site and downloaded a bunch of puzzle/arcade games. I was dismayed to find that many of these games were distributed in formats other than UDIF (the .dmg format). So clearly this matter bears some explanation.
This is the second part of a two-part post. Part 1 came previously; it discussed the difference between compression, archive, and disk-image formats and described the different specific formats in each category. Part 2 covers why you should use a plain dmg (no StuffIt or *zip sprinkles) to distribute your software. This was originally one long post, but I Kill Billed it.
The sad current state of affairs is that much software is not distributed in a plain dmg. Here’s a brief hall of shame, in increasing order of silliness:
I’m not singling any of these products out (especially for .dmg.gz, .zip, and .sit, as these are absurdly common), nor am I critiquing the quality of the software; these are just examples of how not to distribute your application.
Regarding the last one: StuffIt format? WHY?!?!?! Mac OS X doesn’t even come with StuffIt Expander anymore!
And it’s not even StuffIt X (that would be .sitx); .sit is the older StuffIt 5 format, that doesn’t properly support application packages! Worse: because StuffIt 5 format does not support storage of UNIX permissions, StuffIt Expander relies on a preference setting to know whether to set a file as executable or not. So if you UnStuff an application from a StuffIt 5 archive, it might not even run. Doesn’t that make a great first user impression? And who’s going to suspect that their unarchiver is the cause of the problem?
In fact, it isn’t the cause of the problem at all. If you are still distributing your software in StuffIt format, you are to blame.
Panther added support in the Finder for zipping and unzipping files. Tiger added support in the Finder for gunzipping, bunzip2ing, and untarring files. All of these features are the wrong way to distribute an application.
First off, tarring a dmg is pointless. tar files exist to put multiple files into one file. A dmg is already a single file. There is no need to tar it.
Second, if you created your dmg correctly, it is already compressed (probably with zlib). ‘Correctly’ means making a read-only compressed image, either from a folder or from another (read/write) image. There is no need to compress it further. Be very surprised if the additional savings exceed 20 K. (the .dmg.tar.gz listed above is particularly egregious — hello, Mr. Redundancy Man!)
Third, if somebody on Jaguar (or earlier) downloads your zip file, and you created it using Finder, it will not unpack correctly in StuffIt Expander. Specifically, it will create ugly ‘__MACOSX’ folders. Your application might work (unless you actually did intend to use the resource fork for something, in which case it’s gone then), but littering a user’s system is not a way to build goodwill.
Fourth, the purpose of Finder’s zip support is to allow you to send files to Windows users. Distributing Mac software does not count.
There is only one valid use for zip: getting around stupid web servers that either don’t allow dmgs (*shakes fist at GeoCities*) or that don’t have a proper media type (application/octet-stream) set for it. If you have access to add that media type, do so, and distribute a plain dmg; otherwise, politely badger your admin. And until such time as they fix it, you should include a note on your downloads page acknowledging that having to zip your dmgs is lame.
Lest this article sound completely negative, let me explain the upsides of using UDIF.
The major advantage is that it sandboxes your application. An application shouldn’t install anything outside of its bundle (are you listening, Adobe?). If your application is written correctly, it is self-contained (everything it needs is in the .app bundle — this is what bundles are for) and does not require write access to the volume it is on. If your application can be run without problems from the dmg, then you are doing all right.
The second advantage is that a dmg does not require proprietary software (i.e. StuffIt). This seems to be a bigger advantage than it should be — StuffIt does not come with the OS anymore, and requiring people to download other software in order to use your software at all is not a good way to make them fans of it. Disk Copy/Disk Utility has always come with Mac OS X.
(Before you bring up Growl: Growl isn’t required by most of the applications that use it; it’s just value-added. Those applications that do require Growl are aimed specifically at existing Growl users.)
Third: with a dmg, you can easily embed a license agreement. There is no need for an installer to display it; Disk Copy/Disk Utility will do it for you.
That gives me an idea. Here are a couple of points about installers.
Unless you are installing a framework (that really needs to be installed into a Library directory) or a kernel extension, do not create an installer or an Installer package. There is no point.
The user should be able to try your application without installing it (remember what I said about it being usable from the dmg?). An installer is a barrier to this. You should make it as easy as possible for people to try your app.