Category Archiveos x
Note to self & iPhone & mac & os x 28 Nov 2008 03:01 pm
Build and Compile your SQLite Database with Xcode
I’ve been working on setting up a database for an iPhone app. I haven’t worked with sqlite before so it’s yet another new thing to learn. I’ve been going through a few tutorials on the web and was partway through this one when I took the advice of his sidebar at the end of Step 3 to keep my database definition in sql and have it built when the app compiles. He linked to this screenshot by way of a how-to, which unfortunately didn’t work for me.
First off, to find the build rules for your project, right click on Targets in xcode and select Get Info:

I also added a check to see if your db already exists to avoid build errors if it doesn’t. I decided to put it into an external file and execute that from the build rule. Here’s what my build rule looks like:
Here’s the bash shell script:
#!/bin/bash
cd ${TARGET_BUILD_DIR}
if [ -f ${INPUT_FILE_BASE}.db ];
then
rm ${INPUT_FILE_BASE}.db;
fi
cat ${INPUT_FILE_PATH} | sqlite3 ${INPUT_FILE_BASE}.db
Put it in a file (sqlbuildrule.sh, for example) and place it in your project directory and set it to executable:
chmod +x sqlbuildrule.sh
At the end of the rule, click the + below “with output files” and enter this:
$(TARGET_BUILD_DIR)/$(INPUT_FILE_BASE).db
The script will look for a .sql file in your project directory and build it with the output going to your target build directory.
If you need to edit the shell script or change the “with output files” setting of the build rule, note that the way you use the environment variables is different. The shell uses them as regular bash variables: ${MY_VAR}, where Xcode uses parens: $(MY_VAR).
mac & os x 26 Jun 2007 03:27 pm
Migrating user accounts w/o Firewire Target Disk
Perhaps this is an edge case, but recently I wanted to migrate my wife’s account from a G4 Yikes (1st generation G4 desktop machine) to a MacBook. It turns out that the G4 Yikes (aka, non-AGP graphics G4) is the only G4 (or, I believe G3) with built-in Firewire that won’t go into target disk mode.
You can, however, use the Migration Assistant with a mounted volume — if you happen to be able to yank the drive from the old machine and pop it in the new one, you’re good to go. I couldn’t, but had an external Firewire/USB drive. I used SuperDuper! to make a backup of the G4 HD, copied that to the external drive and then migrated from that onto the MacBook.
It worked great, but beware: you have to register SuperDuper! to get the full copy capability. I had registered, but was using a demo copy on the G4 and kept getting only the Users folder copied (which isn’t enough to Migrate from). With the registered version it will actually make a bootable volume.
mac os x
