Saturday, January 31, 2009

Xcode questions and feature wishes

Things I don't know how to do in Xcode, or that Xcode just doesn't do and should:

• Reindent the entire file? I know you can select text and hit C-Shift-F, that's not quite what I'm talking about. One button, whole file, don't move my cursor. Or even better, just turn on the 'always indent my code' mode so I don't have to spend my time thinking about indentation.

• When I finish with run or debug, switch the Xcode back to project mode from debug mode. Why do I always have to hit C-0?

• Jump through your last N edit locations, across all files? C-q in NetBeans, I use this constantly.

• Move the current selection (or line, if there's no selection) up/down?

• Duplicate the current selection (or line, if there's no selection) up/down?

• Delete the current line? I'm aware that I can hit C-l to select the entire line, and then delete it.

• Select by expressions? One key combo, select my current symbol. One more to expand it to the enclosing expression, etc, and the same thing going the other way. I use this all the time in NetBeans.

• Close all editor windows? Close all closes everything - I just want editor windows to go away, leaving the project window.

• Move to the beginning of the text on a line? I know Cmd-leftArrow moves to character position 0.

• Show line numbers in the gutter? I know the line number is shown next to the filename.

• Show an outline of the current file? I want a navigation pane - show me the methods and fields in the file I'm editing. Xcode has the information - I want the dropdown menu in a pane somewhere that I can see all the time.

• Edit/create properties? Properties are painful right now - you have to touch three different places for a single property.

• Edit/create the signature of a method? Give me one place to edit both the .h and the .m.

• I want vertical editing like TextMate.

• Show me the inheritance tree for the class I'm editing, in a pane. Parents, siblings, children, selectable.

• How do you use the refactoring features without Xcode blowing up? OK, more of a rant than a question. But refactoring crashes Xcode too often - I've stopped using it.

• Refactoring needs to add a 'move' to move methods between classes.

• Transform a method call between all arguments on one line/all arguments on a seperate line.

• In the debugger, if you've set up key value observing on an object, and the object is in an array, you can't see its details. You just get a NSKVONotifying_Whatever object that you can't drill down into. This should be fixed. (If the objects aren't an an array, there's no problem.)

• NSDictionary display in the debugger. There's no way to drill down into an NSDictionary.

• Jump to a method or class. In NetBeans, you hit Cmd-O, and the dialog shows you all the available classes. There's a text box to narrow the list of classes, and you can type #methodName in the box to get methods instead of classes. I use this constantly. [UPDATE - Dan Wright on the Seattle Xcoders mailing list pointed out Cmd-shift-D - very handy]

• Better support for code coverage.  Hunting around for *.gcda files isn't a great user experience.

Tuesday, January 27, 2009

This is not the droid you're looking for. Move along, move along.

These show up on the console doing a full iPhone restore:

1/27/09 11:57:48 PM [0x0-0x7b07b][1192] MobileDevice: AMDeviceConnect: This is not the droid you're looking for. Move along, move along.
1/27/09 11:57:48 PM [0x0-0x7b07b][1192] MobileDevice: AMDeviceConnect: This is not the droid you're looking for. Move along, move along.
1/27/09 11:57:48 PM [0x0-0x8f08f][1288] MobileDevice: AMDeviceConnect: This is not the droid you're looking for. Move along, move along.


Monday, January 26, 2009

When you're loading from a nib file, outlets aren't connected until #loadView is called

When you're loading a nib file, the load process is supposed to connect outlets that are set in Interface Builder. And according to the Resource Programming Guide, in the Nib Object Life Cycle section:
When you use the methods of NSNib or NSBundle to load and instantiate the objects in a nib file, the
underlying nib-loading code does the following:
3. It reestablishes all connections (actions, outlets, and bindings) between objects in the nib file. This
includes connections to File’s Owner and other proxy objects.
Having read that bit, I assumed that initWithNibName:bundle: would count as one of those "NSNib or NSBundle" methods. Wrong. Instead, the outlets are connected when the view loads. To figure that out, I just wrote the method to set the outlet I cared about (in this case, it's called editableField) and set a breakpoint in the method. It's not until loadView happens - here's the full stack trace:
#0  -[EditTextField setEditableField:] (self=0x10266b0, _cmd=0x2ceb3, f=0x105afd0) at /Users/jamesmoore/dev/CallWrangler/Classes/EditTextField.m:37
#1  0x93ac2cee in -[NSObject(NSKeyValueCoding) setValue:forKey:] ()
#2  0x93b477c1 in -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] ()
#3  0x30c1f907 in -[UIRuntimeOutletConnection connect] ()
#4  0x93e5cc45 in -[NSArray makeObjectsPerformSelector:] ()
#5  0x30c1e455 in -[UINib instantiateWithOptions:owner:loadingResourcesFromBundle:] ()
#6  0x30c204b8 in -[NSBundle(NSBundleAdditions) loadNibNamed:owner:options:] ()
#7  0x30ac6eca in -[UIViewController _loadViewFromNibNamed:bundle:] ()
#8  0x30ac72af in -[UIViewController loadView] ()
#9  0x30ac7421 in -[UIViewController view] ()
#10 0x30acb01d in -[UIViewController(UIViewControllerContentScrollView) contentScrollView] ()
#11 0x30acd415 in -[UINavigationController _startTransition:fromViewController:toViewController:] ()
#12 0x30acdd23 in -[UINavigationController pushViewController:transition:forceImmediate:] ()
#13 0x30acd95d in -[UINavigationController pushViewController:animated:] ()
#14 0x0001f157 in -[SavedListViewController pushEditingViewForListNamed:] (self=0x1035630, _cmd=0x2b9d4, name=0x1040dd0) at /Users/jamesmoore/dev/CallWrangler/Classes/SavedListViewController.m:115
#15 0x0001f72b in -[SavedListViewController tableView:didSelectRowAtIndexPath:] (self=0x1035630, _cmd=0x30c624d0, tableView=0x103a370, indexPath=0x10402f0) at /Users/jamesmoore/dev/CallWrangler/Classes/SavedListViewController.m:182
#16 0x30a8f74d in -[UITableView(_UITableViewPrivate) _sendSelectionDidChange] ()
#17 0x30a96b4c in -[UITableView touchesEnded:withEvent:] ()
#18 0x30a6790f in -[UIWindow sendEvent:] ()
#19 0x30a56ff7 in -[UIApplication sendEvent:] ()
#20 0x30a561d8 in _UIApplicationHandleEvent ()
#21 0x31563dea in SendEvent ()
#22 0x3156640c in PurpleEventTimerCallBack ()
#23 0x93dee5f5 in CFRunLoopRunSpecific ()
#24 0x93deecd8 in CFRunLoopRunInMode ()
#25 0x31564600 in GSEventRunModal ()
#26 0x315646c5 in GSEventRun ()
#27 0x30a4ec98 in -[UIApplication _run] ()
#28 0x30a5a094 in UIApplicationMain ()
#29 0x0001c620 in main (argc=1, argv=0xbffff044) at /Users/jamesmoore/dev/CallWrangler/main.m:33

Useful threads on the Apple developer forum

I'm going to start collecting the URLs of particularly useful threads in the Developer Forums here.

Bug with UITableView, Swipes and Controls in Cells
Loupe in scrolling UITableView
Responding to view controller memory warnings
code signing provisioning profile - information about signing and ad hoc distribution

Problem with copyplist (caused by an Apple bug + Ruby macports install)

I was trying to build a copy of the example code EditableDetailView, and I was getting an error when the build tried to run copyplist: Building target “EditableDetailView” of project “EditableDetailView” with configuration “Debug”Checking DependenciesPBXCp build/Debug-iphonesimulator/ appData.plist cd /Users/jamesmoore/dev/EditableDetailView setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Library/PrivateFrameworks/DevToolsCore.framework/Resources/pbxcp -exclude .DS_Store -exclude CVS -exclude .svn -resolve-src-symlinks /Users/jamesmoore/dev/EditableDetailView/appData.plist /Users/jamesmoore/dev/EditableDetailView/build/Debug-iphonesimulator/EditableDetailView.appCopyPlistFile /Users/jamesmoore/dev/EditableDetailView/build/Debug-iphonesimulator/ appData.plist cd /Users/jamesmoore/dev/EditableDetailView setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/copyplist appData.plist --outdir /Users/jamesmoore/dev/EditableDetailView/build/Debug-iphonesimulator/EditableDetailView.apperror: can't exec '/Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/copyplist' (No such file or directory) The first check I did was to make sure I had copyplist somewhere on the system:
jamesmoore@james-moores-macbook-pro:~$ locate copyplist/Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/copyplist
That's not in my normal path, but I didn't expect it to be.And anyway, XCode's build is calling copyplist from a specific location anyway - it wants /Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/copyplist and doesn't care about the path. There's a file at /Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/copyplist and it looks fine. But when I try to run it, I get the same thing:
[james-moores-macbook-pro:~/dev/EditableDetailView] jamesmoore% /Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/copyplist/Developer/Library/Xcode/Plug-ins/CoreBuildTasks.xcplugin/Contents/Resources/copyplist: Command not found.
So I open the file, and see the problem immediately on line 1:
Of course there's no /usr/bin/ruby - I do Ruby development, and since Apple ships a version of Ruby that was current back when dinosaurs roamed the earth, I install the macports version. And that goes in /opt/local/bin, not /usr/bin. It's an Apple bug - hardcoding the location of Ruby is wrong. The line should be:
#!/usr/bin/env ruby
The workaround is just to link the good Ruby to the old, bad location:
sudo ln -s /opt/local/bin/ruby /usr/bin/

Monday, January 19, 2009

Installing mysql gem on MacOS

Chris Bailey's blog had the quick answer for how to install the mysql gem in MacOS when you're using the macports mysql:

sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-include=/opt/local/include/mysql5 --with-mysql-lib=/opt/local/lib/mysql5 --with-mysql-config=/opt/local/lib/mysql5/bin/mysql_config

Wednesday, January 14, 2009

screen (as in old-school unix screen) on the mac - UTF8

I finally got around to figuring out screen - should have done it years ago. On a Mac, you're going to get a LANG default like this:
You'll need to put this in your ~/.screenrc:
defutf8 on

Sunday, January 11, 2009

How to get symbolic stack traces on an iPhone exception

Very useful post from Gabriel Handford about getting symbolic information in stack traces. Good followup article from Ben Chatelain about some missing pieces. Gabriel said "For me, DEBUG is set in GCC_PREPROCESSOR_DEFINITIONS via the awesome GTM xcconfg files, which you should also be using," but since I'm not using them, I just added DEBUG to the command line. (Cmd-I on the target > Build > Preprocessor macros). I hit the same issue with NSDebug that Ben had, and copying the file over seems to solve the problem with running on the device itself and not just the simulator.

Thursday, January 1, 2009

Don't run your bluetooth headset through the wash

Turns out a Samsung WEP200 doesn't survive a pass through the washing machine + dryer. Second bluetooth headset I've killed that way. You'd think I would have learned by now.