Search This Blog

Monday, January 30, 2012

Fail: -D in XCode 4.2, Desktop Sort in Lion

So two gripes today.


First, XCode 4.2.  I go in and try and add "-DMIDI_TUNNEL" to "Other C flags" in the Scheme Edit thing.  The newly added definition (MIDI_TUNNEL) then instead magically jumps over under the "Other C++ Flags" section - which LLVM promptly ignores because my files are .m (I suppose equal to .c) and not .cpp.

No amount of screwing about with the (-) and (+) minus things works either - making it seemingly impossible to delete the define.

I could not get this to work though I fiddled around for a bit trying different options. I finally put the "-D" into a header in order to get around it for now.

Since I am being forced into the new XCode paradigm at least make it work right.

Secondly why, in Lion, is the Desktop special with regard to sorting files by name, date, etc.  in the Finder?  All the other Finder windows you see look like they have for a decade.  But now the "Desktop" is different.


Looks kind of like a search result: things broken down by recent, so many days ago, and so on.  Worse you cannot click were "Today" appears at the top to sort the view by date, for example.  No does clicking on Type or Date work.

Nope.

You have to use a new drop down near the top.



However, this now presents new date/time sort options - Created, Modified, Added and Last Opened.

While you can change these options the display always shows the date column as "Date Added" - though clicking the dialog appears to have some effect on file order.

Various open file dialogs now use this new format too - again only for the desktop - and display so much new an useless info that the name of the file is hard to see or doesn't fit so it gets truncated with dots (...).

Jobs dies and, without the boss, the rest of them all run amuck turning everything into iPhones...

Thursday, January 26, 2012

Adding an Application Delegate in XCode 4.2

A lot of time I will create Cocoa projects (iOS is different to some degree) in XCode one way and later realize I need something that's not part of the standard project "Template."  Or, sometimes, you do something in XCode 4 that breaks the project.  For example, removing files the "wrong way" and not being able to get them "reinstalled" without weird compiler or other errors - so its basically faster to "start over."

In any case adding an "Application Delegate" is a common need as in needing an App Delegate to handle functions like "applicationDidFinishLaunching:"

To do this quickly add a new file with File>New>New File.

Create a Cocoa NSObject subclass - call it AppDelegate or something similar.

The .h file should look something like this:

@interface AppDelegate : NSObject<NSApplicationDelegate>
{
  // Put your app-level variables here...
}
@end

The .m similar to this:

@implementation ApplicationDelegate

// Add the code below to handle app startup items...
- (void)applicationDidFinishLaunching: (NSNotification *)aNotification
{
  // Init your app-level variables...
}
@end

In XCode 4.2 a "MainMenu.xib" is (always?) created along with the Cocoa project.  Open it in InterfaceBuilder by single-clicking.

Click the "Show Utilities" in the upper right to reveal the integrated Inspector area at the right (it should slide in from the right).

At the bottom select the "Object Library" (3-D black cube) and search for "Object."  The blue 3-D "Object" cube should appear along with several others.  Drag the blue object over into the area on the left holding other objects (under the black 3-D object cube with "main menu" and "font manager" under it).

Select it and rename its class (using "Custom Class" in the Inspector on the right) to "AppDelegate" or whatever you called your class above.  The object's name should change to "AppDelegate."

Right-click on the File's Owner so reveal the "hookup" menu.  Control-clock and drag from its delegate outlet to your newly named object.  If the hookup succeeds the menu will flash.

Save, build and go...

Tuesday, January 24, 2012

XCode 4.2 and a "From Scratch" Chameleon Build

Link Below...
I have been using "Xcode 4.2 for Lion in the Mac App Store" version 4.2 (the latest version is 4.2.1 which I doubt will make much difference here but I have not tried it  apparently 4.2.1 in the app store is 4.2 in XCode "About"??).

I am working on a project involving MIDI that will run on Mac OS X and iOS devices (as well, some day, on Windows).  My goal is to create a common UI between both Apple systems using "Chameleon."

Chameleon is a "white room" implementation of the UIKit interface on iOS devices (details on the site).

I downloaded Chameleon as a .ZIP and was able to get things to work under XCode 4.2 by simply following the instructions.  However, if I intend to use this in my applications I need to make sure that this will work from scratch.

(You might ask "why not just use the supplied Chameleon project as a base?"  I will never do that because of my past experience.  Often I have found that you get to a point in XCode development projects where the project is broken in some way relative to what you need to do to solve some issue and you want to start over because that's the fastest way.  If the supplied Chameleon project has a problem like this I am, as they say, hosed.

In addition things like XCode 4 - which seem to me ill thought out like Lion - change basic paradigms and there is not easy direct route between say XCode 3.2.6 and where you want to be.)

On the iOS side this was pretty straight forward.  Basically by creating an empty "View" iOS project and installing re-written (new file and class names) versions of each of the Chameleon files.

The result worked as advertised.

However, on the Mac OS X side things were somewhat trickier.  Below are the things I found that made this hard:

First, you need to create new project and be sure to include the "Document-Based" option:


The resulting project will have only a "Document.h" and a "Document.m" source file.  You need to do this because you will need the "Document.xib" file that is also created.

Second, in XCode 4.2 its important to use the Document.h/m files because they are tied to the .xib file.  I fooled around for some hours trying to do this from scratch in a non-Document project without any useful results.

(I redid each of the files with new names and class names just to ensure that I wouldn't have other problems on the OS X side.)

This means you need to merge the MyDocument.h/m contents into the XCode-created Document.h/m files (replace the contents of Document.h/m with the guts of MyDocument.h/m supplied with Chameleon).

Third, you must change the name returned inside windowNibName to "Document" as well.

Fourth, I also had to edit the #import <UIKit/UIKit.h> imports to #import "UIKit.h" and include the locations of the "Classes" folder in the supplied Chameleon UIKit sub-project.   Without this XCode cannot resolve the #import.

Fifth, I also put the .XIB files into Resources sub-folders.

Six, you need to add the Chameleon UIKit project to your project and then open "Targets>Build Phases>Link With Binary Libraries."  Click the plus (+) and select "UIKit.framework".  Be careful here because removing things and adding them back, like the UIKit project seemed to cause problems.

Finally, I rebuilt all the Toolbar and main window in InterfaceBuilder.  I manually checked to make sure everything linked together between the various IB elements and my classes.

The result worked just as the distribution did.

Now I am moving on to install my iOS code into Chameleon to see how well it works.

All told this was far less work than re-writing my code or creating the equivalent to Chameleon.

(Relative to XCode 3.2.6 - creating empty projects behaves differently than XCode 4.  Basically they do two completely different things and importing the older version to me is just asking for trouble.

A lot of XCode 4 to me seems like it involves doing things "just so" - and if you don't know what that is you are lost (see this as an example).  XCode 3.2.6 was quirky but usable because it did much less "magically" for you.

IB is also an issue here - it seems like each release works slightly differently than the last - and mostly in ways that involve an hour of Googling to find that one thing that's missing.)

Sunday, January 15, 2012

Kronos Software Updates

You will need: A FAT-32 formatted USB drive - about $20.00 USD at Walmart.

Updates are located at www.korg.com/kronos.  Select "Support & Downloads" and click the "OS" tab.

Download the update "KRONOS_Update1_5_0.zip" and un-zip the downloaded file.

Copy the following files to the USB drive.

  - mnt (Folder)
  - KRONOS_Update1_5_0.taz.gz
  - install.info
  - posttar.sh
  - pretar.sh

The KRONOS is a realtime Linux-based PC (basically) so you are supplying a new OS along with a new set of application tools (what you see on the KRONOS screen, drivers, etc.)

The "pretar" code does this:

#!/bin/sh
# Kronos installer preparation script
rm -fr /mnt/updaterSource/mnt/lib/modules/2.6.32.11-korg/kernel/sound
kill $(pidof vsftpd)
kill $(pidof avahi-daemon)
kill $(pidof messagebus)
kill $(pidof ifplugd)
sleep 2
kill -9 $(pidof vsftpd)
kill -9 $(pidof avahi-daemon)
kill -9 $(pidof messagebus)
kill -9 $(pidof ifplugd)
sleep 2


Basically this looks like a macro substitution program fills in the pids (process IDs) of the various processes running in RTLinux which are killed off before the install begins (perhaps the things being updated).

The .GZ contains the OS Update.  A quick unpack on Mac OSX fails - probably because its encrypted (no doubt using some info in "install.info" or a standard Korg PGP key of some sort).

In any case, after you've put the USB drive into one of the Kronos USB ports (and disconnect all the other drives and USB cables) you can do the install:

1. Go to the Global P0 – Basic Setup page (Global button - Menu on upper right).

2. Select “Update System Software”.  If it sees the USB drive it will let you know.

3. Press the OK button and a dialog will appear saying: “Are you sure?” Press the OK button.

4. Let the update run and DON'T TOUCH ANYTHING.

5. When the update is complete “Kronos system version 1.5.0 update complete. Please restart the system” will appear on the LCD display.

6. Turn off the Kronos, and then disconnect the USB storage device, wait 10 seconds, and turn the Kronos back on.


7. The boot display ("Kronos") doesn't list the version until after the red progress bar is almost all the way right.  Then the OS Version will appear.

The first time I did this it didn't work and still said 1.0.4.  I went through the steps above again and the second time it seemed to work (the boot sequence flashes the "Disk" light differently in 1.5 as compared to 1.0.4).