Saturday, July 17, 2010

"(class) may not respond to (method)"

Man, that message gets annoying. It's easy enough to get rid off, just put the method declaration in the interface/.h file. But maybe you don't want in the interface. You're calling it from within the class, why can't the compiler find it? Beside, your app runs fine regardless of the warning. Say you have the following:
- (void) applicationDidFinishLaunching:(NSNotification *)aNotification {
[self someInitialization];
}

- (void) someInitialization {
// Do some stuff
}
Swap the two around so that the method being called comes before the method doing the calling:
- (void) someInitialization {
// Do some stuff
}

- (void) applicationDidFinishLaunching:(NSNotification *)aNotification {
[self someInitialization];
}
And "ta da!", the warning goes away.

I'm not a particularly big fan of having to reorder my methods to please the compiler but I'm even less of a fan of having compiler warnings even when I know they're innocuous.

Wednesday, December 30, 2009

Integrating git and Xcode

The Subversion and Xcode combination has been way too flaky for my tastes. I've tried to keep the repositories on a central machine in the house without success. When the hackintosh was my main dev machine, I used it as the central location for the Subversion repositories. When I'd got to synch from the hackintoshed MSI Wind, it would sometimes work, and more often than not I'd get "network connection shut down unexpectedly". When the Mac Mini went in as the home entertainment computer, I tried moving things to that machine. Results were better, but still not reliable. I would still have to try several times, or quit Xcode and restart. Sometimes I would just have to give up, let check-ins pile up, and try again later.

This clearly wasn't going to fly, despite having put up with it for six months. If I was going to move to something else, it might as well be one of those cool distributed source control systems all the kids are using these days. I looked at Mercurial, git, and gave a passing glance to Bazaar. I thought I could get Mercurial onto the MyBook World, but that didn't go as smoothly as planned. In the end, I settled on git, and for no particular reason other than github offers a nice setup for cheap. I can get to it from anywhere, so if I forget to synch the changes made on the iMac to the Macbook before getting on the bus, I can do it on the bus if it has WiFi (which the Sound Transit 545 usually does). Write code on a plane, and commit as soon as I get a connection. I do a lot of my iPhone/OS X coding offline, and I like frequent commits, so being able to commit from anywhere I had an Internet connection was a big plus. Other than that, the other two options would probably work well for my purposes as a one-man shop.

But is there a way to keep that same sweet (albeit flakey) Xcode integration that one gets with Subversion? Apparently there is not. There is a GUI in the form of Gitx, but it apparently doesn't do remote commits (that's just what I read, I haven't even tried yet.) No matter, it's not like working from the command line is that hard with git. git commit, then git push, and we're done. Zack Rusin has a really good cheat sheet that I've found to be quite handy.

However, following the usual instructions on setting up the repository left a bit of a mess at first. Sure, it's easy to cd to the root of the Xcode project and do a git add .. You'll be in for a surprise when you check the repository after doing a push, though. Everything in the build output directory gets pushed, as well as some other artifacts that you probably don't want in the repository.

Want you want to do before executing those easy git commit/push commands is to create a .gitignore file in the root of the project directory. Shane Vitarana has exactly what you need to cut and paste into .gitignore, as well as what needs to go in .gitattributes so that git treats the Xcode project file as a binary and prevents git from trying to fix things that don't need fixing.

With that done, it's a simple matter of keeping the cheat sheet handy, a terminal window open, and typing a few short commands once in a while instead of right-click/Commit in Xcode.

Saturday, December 5, 2009

MyBook World Edition II Optware Install

I have a 1TB MyBook World Edition II NAS. It's a decent drive for the money, if a bit slow (actually, a lot slow). Like an competent dev, I use source control, and specifically Subversion since it's integrated into Xcode. But in order to access the repository from any machine in the house, I need to keep a machine running. Previously this has meant the hackintosh. The desktop hackintosh is a decent machine, but super noisy, and I'm not a fan of keeping it running if I don't have to.

Enter the previously mentioned MyBook. It runs Linux, Mercurial is Python, I should be able to get the two playing nice. The first step is getting Optware on the thing so I can pull down the packages, and that's where I spent way too much time this morning. My MyBook is the LED white light edition. This apparently means something, as I was unsuccessful in getting a working installation following the instructions found in various places on the web. Post-install, it was "ipkg: not found". No amount of environment or chmod fiddling seemed to help. Then I tripped across the instructions at the bottom of this page.

I figured I had hosed my setup at this point, so I reset the version number and downloaded the latest firmware again. I then downloaded and executed the following (from the bottom of that page):
wget -O prep_whitelight http://wd.mirmana.com/prep_whitelight
sh prep_whitelight


The script takes a long time to run, but it is doing a lot to make sure things are working, and (from my reading) will bail out if things go wrong to avoid screwing up the MyBook. That got got Optware working, so now I can install Python:
/opt/bin/ipkg list | grep python
/opt/bin/ipkg install python25