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.

18 Aug 14

Cisco AnyConnect VPN problems on android:

AnyConnectI’ve been using cisco VPN on android. It works pretty well, but sometimes, I would run into an issue where DNS wouldn’t resolve while connected (e.g. fails to load in chrome and says DNS host lookup fail). This would happen and leave me out of luck for a week for that device. The internet, of course, advised me to restart, of course. (someone else probably said I should zap my pram on my mac and see if that fixed it). Then I started getting the error when connecting to VPN:
"System configuration settings could not be applied. A VPN connection will not be established."

Turns out the problem I was having was that the IP Settings for my wifi connection were ‘static’, and they should be ‘DHCP’ so the dns can be updated to pull the VPN’s DNS to resolve hostnames properly. DHCP is usually the default, but someone probably changed this shared device to a static connection, which lets you override DNS. To do this you go to your settings app, then wifi, then *press and hold* the wifi connection you are on. On other devices there might be some other way of getting to the wifi details screen, but it should look something like this:


Make sure you are on DHCP and not static. If there’s a box that says ‘static’ uncheck it. If your router is special and doesn’t let you do DHCP, you might not be able to use Cisco VPN from that connection.

Also, this seems to fix those pesky timeouts after 30 minutes to an hour (I guess something was pumped via DCHP that lets the connection live.

27 Apr 14

pop quiz: why are my parameters zero when I pass them in with non-zero values

This one had me stuck for a number of minutes. It’s not hard, but it got me. See if you can spot it:

say you create a new class that is inited like so:

@interface YoDogWhatsWrong
@property (nonatomic) float aValue;
@implementation YoDogWhatsWrong
- (id)initWithAValue:(float)aFloat anotherValue:(float)someOtherValue
    if ((self = [super init])) {
        self.aValue = aFloat;
    return self;

and you call it somewhere with

    YoDogWhatsWrong *notCreatedProperly = [[YoDogWhatsWrong alloc] initWithAValue:180 anotherValue: 0];
    NSLog(@"aValue is %f", notCreatedProperly.aValue);

and you find that to your dismay that ‘aValue is 0.0′. There’s something wrong here, and it is worse than your lack of creative variable names.

Did you spot it?

Did you?

Well, Obj-C doesn’t have a compilation error if you don’t have a method declared in the interface and you still call it, but it does give you a warning. If you’re anything like me, you’ve probably abused this before when you’re hacking away at the implementation, with the intent of adding the methods that are used publicly. Well, most of the time you can get away with this, because many of the times the parameters are objective-C objects. In this case they were floats, and unfortunately, either the obj-c spec the compiler assumes a default calling convention that was of type ‘id’ instead of float, and sizeof ‘id’ was larger than sizeof(float) here. The rest of the story should be clear now: the first parameter in the init method got the upper half of the bits of ’180.f’ which is just zeros, and the next parameter got the lower half.

This weird behavior will also happen if you forget to include a header for a method that uses (float) or some other primitive type. A lot of bad stuff can be avoided by keeping a zero warning count, or at least, looking at your warnings regularly.

So to fix the problem, simply add the method declaration to the interface, like you (I) should have been doing all along:

@interface YoDogWhatsWrong
@property (nonatomic) float aValue;
- (id)initWithAValue:(float)aFloat anotherValue:(float)someOtherValue;

FYI this was on the iOS simulator 7.0 4 inch (not 64 bit) and (disclaimer) I haven’t compiled any of the code on this post.

28 Dec 13

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

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 "" did not have bundle identifier
So I looked in the directory that contained 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

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.