Apple Undocumentation

Filed under:MacOS X — posted by admin on December 31, 2009 @ 6:00 pm

This used to be in Apple’s documentation about how to create flat executables (such as command line tools) that have Info.plist data. The information is gone from Apple’s site now. Still, it may be useful:

Putting Info.plist Files in a Flat Executable

Even if your program does not use the bundle structure, it should still include an information property-list file to identify key pieces of information to the system. For unbundled CFM executables, you can place the contents of the program’s Info.plist file in a ‘plst’ resource. For unbundled Mach-O executables, you can create an __info_plist section in the executable’s __TEXT segment and put the contents of your information property-list file there. To create an __info_plist section, you would create an Info.plist file as you would for a bundled program and then add the following linker options to your makefile or Xcode project:

-sectcreate __TEXT __info_plist Info.plist

To retrieve the Info.plist information, your unbundled program can use many of the CFBundle functions for accessing bundle properties. Although your program is not bundled, you can still get the “main bundle” and pass that object to any functions you call.

Update: It looks like it just got moved instead. It is now in the Code Signing Guide.

Debugging Javascript in Safari

Filed under:Web Development — posted by admin on October 1, 2009 @ 10:19 am

When I need this, I use it every day, 38 times a day, for a week. Then I forget about it. No more.

For quick-n-dirty Safari Javascript debugging, try “window.console.log()”.

Hidden tricks in the Xcode editor

Filed under:MacOS X,Perl — posted by admin on June 30, 2009 @ 9:49 am

I’m quite fond of Xcode’s built-in editor. I have no problem with anyone trying to write the Next Great Programmer’s Editor, but the bar is pretty high. I use Xcode for almost all of my programming, including web sites and Perl.

In C, you can use the #pragma mark directive to add a comment to the function listing at the top of the window. In Perl, you can do the same with “TODO:” comments. However, I wanted to see if I could add a mark without having to use “TODO:”. I dug around and found the XcodeEdit private framework and discovered the syntax files for the Xcode editor. Here is the full list of marker codes:

  • TODO:
  • FIXME:
  • !!!:
  • ???:
  • MARK: This one is special. You don’t get the mark, just the text!

Back to work!

Xcode project and file templates

Filed under:MacOS X — posted by admin on June 19, 2009 @ 5:24 pm

I’ve known about Xcode project templates for quite a while. I even wrote a little script once that would take an Xcode project and convert it into a template. All you had to do then was copy it to a magical place in your home directory and you had custom Xcode projects.

Unfortunately, there was no way to setup file templates. If you went to Xcode File -> New File, you would get the Xcode default files.

As of Xcode 3.1.2, there are improvements. You can now specify both project and file templates. Go to /Library/Application Support/Developer/Shared/Xcode. You can create Project Templates and a File Templates directories. Copy your favorite default set from /Developer/Library/Xcode/ and edit the files. Now, just like in New Project, there will be a set of User Templates in the New File dialog box in Xcode. Of course, none of this is documented.

Don’t forget to store your templates somewhere in your home directory and use symbolic links in the system directory. That will help with upgrading.

Thanks to the MacFUSE project for tipping me off.

Paths in MacOS X

Filed under:MacOS X — posted by admin on December 30, 2008 @ 10:22 am

A while back, I installed git to download some random open-source code that I’ve since forgotten about. I noticed this when hacking on my .bash_profile paths to add ImageMagick. I saw that git had been inserted into my path and I couldn’t figure out how. I thought they had been screwing around with my system bash scripts but no – something else was going on…

It seems MacOS X has a little known improvement to UNIX life on the desktop. Instead of adding paths login scripts, you can put them in the /etc/paths.d directory. Add a unique text file whose contents are the path to add. You don’t get control over the order of loading, but that (usually) shouldn’t be a big deal. There is also a /etc/manpaths.d as well.

I normally don’t like to put third party stuff in / directories. That is where things get lost when upgrading. I don’t know if I should use this or not, but I don’t want to forget about it.

MacOS X Application initialization and shutdown sequence

Filed under:MacOS X — posted by admin on December 6, 2008 @ 2:41 pm

Perhaps this is it?

  1. main.m calls the NSApplicationMain function.
  2. init methods of classes in the main nib file
  3. awakeFromNib called on classes instantiated by the nib
  4. [NSApp run]
  5. [NSApp finishLaunching]
  6. Any windows in the nib that were marked as ‘visible at launch time’ are put on screen about now.
  7. applicationWillFinishLaunching:
  8. application:openFile:
  9. applicationDidFinishLaunching:
  10. <run main loop>
  11. applicationShouldTerminate:
  12. reviewUnsavedDocumentsWithAlertTitle:cancellable:delegate:didReviewAllSelector:contextInfo:
  13. closeAllDocumentsWithDelegate:didCloseAllSelector:contextInfo:
  14. <didReviewAllSelector>
  15. applicationWillTerminate:

Updated to add information from this post.

Custom Perl modules

Filed under:Perl — posted by admin on September 19, 2008 @ 5:48 pm

I may need a Perl category here shortly.

Once again, I have had to re-find the following information about doing custom installations of CPAN modules. Here are the details…

$ PERL5LIB=$HOME/lib/perl5/5.8.7:$HOME/lib/perl5/site_perl/5.8.7

$ perl Makefile.PL PREFIX=~/lib

$ make
$ make install

Kill runaway queries in MySQL

Filed under:OSS — posted by admin on @ 8:06 am

OK, this is neither a MacOS X nor a programming item. But I’ve had to look it up twice now. To kill a long-running or runaway MySQL query, follow these instructions:

show processlist;

kill <id>;

Building Universal Binaries on 10.5

Filed under:MacOS X — posted by admin on March 8, 2008 @ 4:26 pm

A new addition is required to build Universal Binaries in 10.5. Add “-isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc -mmacosx-version-min=10.4″ for a 10.4 build.

Going where you want

Filed under:MacOS X — posted by admin on October 4, 2007 @ 8:11 pm

I know this blog is supposed to be about programming. But we programmers sometimes like to squirrel away files in odd places. The standard MacOS X file open dialog doesn’t let you get to those places. Or does it?

I remember long ago finding a keyboard shortcut that would pop up a little window in a file open dialog that would let you type in a path for a directory. Somehow, I managed to find it again. This time, I shan’t forget it.

The keyboard shortcut is Shift-⌘-G


next page


image: detail of installation by Bronwyn Lace