In debugging a particular problem when using someone else’s framework, one often needs to head to documentation for help. At this point one can go to the documentation, or google his exact problem. I tend to go for the latter as a first attempt. Then there are times where I do both for hours and still cannot find the solution though docs or google hits. These are really frustrating, so when I finally fix them I’ve decided to post the solutions here in case they can help someone else. They may need clarification. Just ask and I’ll quickly respond if I can remember.

28 Dec 13
08:45

Android Dev Console Wallet Registration: Error 400

If you’re setting up IAP for the first time on your google dev console, you will probably need to setup google wallet for merchants.

I ran into a silly bug where I fill out the form and always got a message that read:

An error occurred {“type”:”PLATFORM_ERROR”, “payload”:”400″, “request_id”:”4EDF17245AA00.A803E4F.6DB2″}

Emailed support a couple times, turns out to be that you can’t have a P.O. box address listed as your address on this form. It would be nicer if they could just say that in an error message. Hope this saves someone a day.

07 Apr 13
03:45

XCode: Dealing with “Could not inspect the application package” error

After setting up a new cocos2d-x project and having run successfully, after some minor changes I hit this weird error that had only a few hits in google, with no clear solution. To fix it I did the following things. I don’t know which one is the right solution.

1. There was a mostly unhelpful SO question – I tried cleaning to no avail, but the question reminded me to look in the device console (XCode Menu->Window->Organizer->IPhoneDeviceName->Console) to see what the error was. It was odd that the warning was in there:
peruse_package: App info dict loaded from "whateverMyAppBuildNameIs.app" did not have bundle identifier
So I looked in the directory that contained whateverMyAppBuildNameIs.app and think I saw that there was no info.plist. I added the info.plist to the target by clicking on it in XCode and clicking the box in “Target Memebership” on the right (Note: this is probably wrong as I had to undo this later – but it fixed the error and led me to a new one).

2. This gave me a new error that was already in SO where the selected answer did not apply – for some reason I got a “Could not launch myAppName – no such file or directory”. No idea why – I checked that the app existed at the directory. I did some combination of cleaning, deleting the app from my device and restarting xcode, and I got to the next error.


3. I then got a “XCode cannot run using the selected device – Choose a destination with a supported architecture in order to run on this device”. Okay, at least this was logical. So I added armv7 and armv7s, since I noticed these were in the target architectures but not in the valid ones (see screenshot). And then I cleaned, deleted the build dir at Users/your_usr_name/Library/Developer/Xcode/DerivedData/myappbuilddir12312314 manually, and then at some point I removed the target from info.plist (undoing step 1) and then it worked.

There’s a bunch of steps there were probably not necessary, especially since I had to redo one. As usual I’m too lazy to go through the bug again to disect it, I’m just posting this as a quick log. Please comment if you have a better clue than I do about any of the steps. It’s quite possible just the very last steps (everything in 3.) will fix it – if I had to bet money I would go with that. Putting everything in front of you in case it helps.

21 Dec 12
18:46

XCode 4 with a networked drive: fixing ‘null character(s) ignored’ and ‘missing @end’ warnings

RIP command-option-up header/source switching, format indent

XCode 4 had a lot of changes over 3.x. Some seemed kinda okay, others seemed horrible. When it came out I did… absolutely nothing, for as long as possible and held on to the 3.x version as long as it was possible to do so.
Since I had to switch to the iTunes-ized Xcode 4, I’ve been using it only as a compiler/debugger, doing all my text editing in emacs on my linux box, using synergy to swap to my mac to compile. I want my editor to be on the same box as as the source code files in case something weird with the network or filesharing service happens. So the project I compile on my mac is served by smb on my linux box. This may sound needlessly complex, but I like having two boxes even after trying dual-screen mac. Also, I had already set up smb to my liking before trying it out, and I already was playing with this even while xcode 3 was current.

With XCode 4, I noticed something weird happening when I made multiple saves in a short duration, e.g. two quick saves in under a minute. The saved changes wouldn’t go into the build for whatever reason. I remember a similar bug with XCode 3, but if you just waited a second and recompiled, it would be okay. But with XCode 4, sometimes the new changes would never get propogated across the network and compiled even after waiting for a long time. I eventually realized if I saved the file on my linux box again by making a small edit, XCode would pick it up and compile it, but oddly enough, only if the save happened a minute or so after the first.

However, after inspecting the fileshared source code on my mac with other editors, it was clear that this wasn’t a filesharing issue, but simply XCode caching the file. The “Touch command” that existed in XCode 3 would presumably fix this (although I would be afraid to use it if caching is the suspect), but it was inexplicably removed with XCode 4.
When the caching is an issue, you get a warning that looks like ‘null character(s) ignored’ or an error that says ‘missing @end’ and sometimes the file will be cut in half in XCode.

After dealing with this for over a year I just found out you can prevent these by making sure you have no source files open in XCode. It seems the editor uses it’s own cache, and the compiler goes directly to compiling the cache instead of the disk. Note that if you click on an error in the left side panel, this opens up the editor. So now I just create a new tab with a .png file and close all other xcode tabs. When googling this issue over the last year I saw no mentions of this bug, so maybe no one else uses XCode networked. Noting here just in case.

14 Oct 12
20:31

Fixing guake transparency with metacity slow alt-tabbing (ubuntu)

I like guake as my terminal because I can full screen and half screen prettier than the gnome terminal (I can hide the tabs too).
One part that is important for prettiness is transparency. Some will say that this is just eye candy, but it helps me to monitor chatrooms while I program in full screen with 90 percent opacity.
I can only get guake transparency to work by enabling metacity with

gconftool-2 -s '/apps/metacity/general/compositing_manager' --type bool true

But there’s a catch. Enabling metacity makes alt-tabbing take a few seconds on my machine. This is even after you go into compiz settings and set the display delay in the application switcher to zero (which is possibly the most useless feature that ever existed). Turns out the issue is in metacity.

This page goes over the bug and has a patch that is not applied (although I’m still on natty.
I’m copying it here for convenience. You can save it to a file called metacityalttab.patch and put that in the metacity directory you will create in the next step.

Index: metacity-2.30.3/src/core/screen.c
===================================================================
--- metacity-2.30.3.orig/src/core/screen.c 2011-08-30 22:55:19.000000000 +0400
+++ metacity-2.30.3/src/core/screen.c 2011-08-30 23:02:19.000000000 +0400
@@ -1285,7 +1285,6 @@
       entries[i].key = (MetaTabEntryKey) window->xwindow;
       entries[i].title = window->title;

- win_pixbuf = get_window_pixbuf (window, &width, &height);
       if (win_pixbuf == NULL)
         entries[i].icon = g_object_ref (window->icon);
       else

You can then download the source, patch, build and install with this

#patch an apt-get package (metacity example)
mkdir metacity
cd metacity/
apt-get source metacity
#you may need to play with -p0/-p1
patch -l -p0<metacityalttab.patch
sudo apt-get build-dep metacity
#cant remember, but maybe you need to cd to within the metacity dir for this
dpkg-buildpackage
#if you are running 64 bit use the 64 bit deb in the same dir
sudo dpkg -i metacity_2.30.3-0ubuntu8_i386.deb

After this, you won’t see the changes until you restart.
If you’re like me and hate restarting more than risking crashing you can try killing metacity and restarting it.
I don’t know if there’s a better way to do this, or if this is even dangerous, but I seem to have survived.
Although, killing metacity will in fact make your windows look really weird for a second.
You might also first disable metacity to be safe.

gconftool-2 -s '/apps/metacity/general/compositing_manager' --type bool false
killall -9 metacity
nohup metacity>/dev/null &
gconftool-2 -s '/apps/metacity/general/compositing_manager' --type bool true

After that alt-tabbing should be fast as it should be, and you should have transparency.
And all was well again.

05 May 12
18:10

Use NSMutableData with NSCoder if you will move the data or die

I recently implemented dynamic loading-unloading of audio buffers so I could do real time effects/recording with unlimited lengths on my app. (The core data stuff wouldn’t cut it).

It was working well, except that my save functions got all screwed up and ended up sounding all glitchy and out of order like some kind of accidental fennesz. That’s pretty useful and was almost as fun as the time I discovered Yasunao Tone’s Wounded Man stuff but I prefer to have save working.
I was using NSData to encode via encodeDataObject for my NSCoder. The thing is, as you see in the code sample below, I am dealing with large amounts of data >100 MB, so I am loading and unloading the data before and after the NSData creation and it’s encodeDataObject call. I thought this would be fine since I expect the encoder to write immediately. Instead, it appears it does not write immediately, and there is no flush method to force it to write the data, meaning that if you modify the data in NSData even after it is out of scope, it will end up writing something other than you intended.

If you use NSMutableData, however, it writes immediately.
I understand that NSData is immutable. However, since I was creating with dataWithBytesNoCopy: I was using my own data and thought it would finish by the end of encodeDataObject.

Next.

- (void)encodeWithCoder:(NSCoder *)encoder
{
   [encoder encodeInt:channels forKey:@"channels"];
   [encoder encodeInt:numFrames forKey:@"frames"];
   [encoder encodeFloat:averagePower forKey:@"power"];
   // encodeArrayOfObjCType takes into account sizeof(SInt16) via the type parameter, so we don't computer
   // actual memory size, but the number of SInt16's in the array
   size_t bufsize = channels * numFrames *sizeof(*buffer);
   // use NSData to encode but do not free the buffer when it releases
   [self fetchBuffer];
   NSData *data = [NSMutableData dataWithBytesNoCopy:buffer length:bufsize freeWhenDone:NO];
   [encoder encodeDataObject:data];
   [self unfetchBuffer];
}