Luke Tupper Consulting

Luke Tupper Consulting Blog

How to get iOS debug symbols for arm7

December21

I was having a bit of trouble finding how to get the line number for a crash report. I kept getting the message “atos cannot load symbols for the file” when trying to run atos.

I found this post on Stack Overflow has the correct answer:

http://stackoverflow.com/questions/7675863/atos-cannot-get-symbols-from-dsym-of-archived-application

Removing those .DS_Store files from your project

March27

Handy little script from the cocoabuilder archive.

View .DS_Store files:

find . -type f -name ".DS_Store"

And then to delete them:

find . -type f -name ".DS_Store" -delete

Having problems with sqlite3 gems on MacOSX

January18

Using rails 1.9.2p0 and rails 3.0.3 I was having a problem whenever I ran db:migrate, I got the following error:

no such file to load -- sqlite3

Running bundle install didn’t fix the problem. Turns out that you should only be referencing sqlite3 in your Gemfile, having gem 'sqlite3-ruby', :require => 'sqlite3' in your gemfile will give you at least 1/2 an hour of grief.

Fixing the Dead Ubuntu Boot Disk

January15

A ubuntu machine here got hit by a power glitch during a recent rain storm. When it rebooted it wouldn’t mount the file system.

All the advice seems to point to running fsck from a ubuntu live CD. Using both the latest MythBuntu and Ubuntu 10.10 based live cd’s any attempt to do any sort of fscking on the hard drive would report that the drive was in use. The disks wouldn’t mount, and they weren’t mounted anywhere. No matter what utility I used I constantly got an error reporting the drive was in use.

I never worked out what exactly needs to be done with the livecd, but I downloaded Parted Magic and it worked like a charm. Booted up, using gParted opened up the drive and selected the troublesome partition. A quick check of the partition, and everything was restored without a hitch. I will definitely be keeping a copy of Parted Magic for any future hard drive issues.

Ruby, Rails & Scaling Images

January6

I have been impressed with the speed boost using Ruby and Rails to get everything done building out a simple backend admin website, but then I need to scale an image.

Ruby is fantastic, I had a sample script running on the command line with the ImageScience gem and it only took 6 lines of code to open and existing image and output it in two different sizes. I had all this running and assumed that doing this in rails would be a simple task…

Now I realise that the software I am using is beta and with an open source community not everything happens at the same time. I am sure these bugs will be fixed over time, so don’t apply these fixes unless you are using the same setup.

Current setup:

Ruby: 1.9.2p0 (rev 29036, Darwin X68_64)
Rails 3.0.3
RMagick 2.13.1
ImageMagick 6.6.6-30+q16

Trying to get Image Science gem and rails working together just doesn’t seem to work. There is some changes in one of the dependency gems that rails needs but causes Image Science to break. I tried some of the patches people have put online, but none of them seemed to fix my predicament. Fixing the bugs seemed beyond my current ruby/rails level of skill. I was hesitant about going with RMagick as I know ImageMagick has a tendency to be a complete pain to install, especially on web hosts.

I then went and installed ImageMagick and the RMagick gem as per the MacOSX port based instructions. This installed correctly but was causing a segmentation fault when calling read on Magick::Image.

To fix this, I needed to uninstall ImageMagick, and edit the way ImageMagick is built.

To uninstall:

sudo port uninstall ImageMagick

To edit the installation:

sudo port edit ImageMagic

This will bring up your editor, scroll to around line 100, and add the option –disable-openmp to configure.args. On my machine the section looked like this:

configure.args --enable-shared \
--enable-static \
--disable-ltdl-install \
--with-frozenpaths \
--without-openexr \
--disable-hdri \
--disable-openmp \
--with-dps \
--with-bzlib \
--with-fontconfig \
--with-gslib \
--with-jpeg \
--with-lcms \
--with-png \
--with-tiff \
--with-zlib \
--with-modules \
--with-xml \
--with-x \
--without-perl \
--without-fpx \
--without-jbig \
--without-jp2 \
--without-wmf \
--without-gvc \
--without-rsvg \
--without-lqr \
--with-gs-font-dir=${prefix}/share/fonts/urw-fonts

So apart from some bugs in my code everything was working fine… until I tried running this on my MacBookPro hoping to show the client in 45minutes. Checked out the repository, and everything was setup the same as above, except that the MacBookPro crashed WEBrick (test web server) with a error of: ‘Trace/BPT trap’ as the only output.

Not sure what the difference between the two machines was, but removing the ‘require ‘RMagick’ from the controller made the problem go away.

Having now spent a couple of hours running around in ruby configuration hell, I get back to the task of issuing a few commands on the command line and building out the website quickly and easily. I new all this easy development must be to good to be true. I just dread the installation when I have to deploy this to a linux host (next weeks problem).

posted under Rails, Ruby | No Comments »

Doing Big Text in UITableView

September6

If you need to display differing size text in a UITableView here is some sample code that uses standard UITableViewCells and changes the height depending on the size of the Table View (handles rotation ok).

The main sections of code is the heightForRowAtIndexPath:

NSString *bigText = [self.bigTexts objectAtIndex:indexPath.row];
CGSize textSize = [bigText sizeWithFont:self.labelFont
constrainedToSize:CGSizeMake(tableView.frame.size.width - 40.0, MAXFLOAT) //40 should be the margin needed for controls etc.
lineBreakMode:UILineBreakModeWordWrap];
return textSize.height;

And the initialisation of the TableViewCell:

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

// Configure the cell.
cell.textLabel.numberOfLines = 0;
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.textLabel.text = (NSString *)[self.bigTexts objectAtIndex:indexPath.row];
cell.textLabel.font = self.labelFont;

return cell;

I have uploaded the complete project for those who want to run it straight out of the box.

Searching for files with content via Linux Command line

June28

I needed to search for files with a common bit of content on a host that I had connected to ssh.

This example searches all php files for ‘Search Term’, it search every sub directory from the current directory and prints out the name:


find . -name "*.php" -exec grep -l "Search Term" {} \;

Simple iPhone Table Example

July19

Unless you are building a custom UI (like a game) on the iPhone you probably spend a lot of time working with UITableVews.

I often found it difficult to find good simple examples of iPhone TableView code.

This first sample shows three different uses of UITableView:

1) Very basic table
2) Table that can be resorted.
3) Table that can be resorted with the first and last rows locked in place.

Click on the plain/grouped segment control to choose which style of table you want.

Table Sample

Cocoa Quick Tip: Insert/Delete Icons not displaying on Table

July7

Had a bit of an issue that took me a bit of head scratching. I had a UITableView which worked perfectly in iPhone API 2.2 but in 3.0 the insert/delete icons weren’t being displayed. Reworked and checked all the code but nothing worked.

It seems if you set the editing flag to YES when creating the tableViewCell’s, the insert/delete icon applied by the table delegate (editingStyleForRowAtIndexPath) isn’t displayed. Removing the call to cell.editing seems to fix the problem. This seems to be one of those things that is slightly different between iPhone OS 2.2 and 3.0.

iPhone 3.0 UIButton in a UITableViewCell Weirdness

June25

I had a UIButton inside a UITableViewCell and these were being rendered with a black background once I had upgraded the project to iPhone OS 3.0. These table cells were being loaded from their own NIB file.

To stop the black background I needed to set the background of the TableViewCell to white (like you do on most cells after the upgrade), but for the button I also needed to set the UIButton to have the “Clear Context Before Drawing” setting checked.

The background should still be transparent to allow the corners of grouped tables to be shown.

« Older Entries