10 Jan 15
19:06

Xcode: Semi-stale libraries and the simulator

xcode plays dirty when updating .a

xcode plays dirty when updating .a

Edit: (2/8/2014) As usual, I’m an idiot – this problem was caused by having explicit linker library search path flags (e.g. -LTo/My/Old/AdMobDir) that took precedence over the new libs I added. It didn’t matter that I removed the old ones from the Xcode and git, because they were (oddly) specifying an external directory that had a copy of the same libs. I’ll leave this post up to remind myself about this, at the expense of my credibility.

Today it is my birthday, so I thought how fun it would be to update AdMob for an iOS app. Since it’s just .a and .h files, it would be doable in under a minute. But after updating, I still got the message:

2015-01-10 20:40:24.194 Noise[13472:10630180] You are currently using version 6.5.1 of the SDK, which doesn’t officially support iOS 8. Please consider updating your SDK to the most recent sdk version, 6.12.2, to get iOS 8 support, including a fix for smart banner rendering in landscape mode. The latest SDK can be downloaded from http://goo.gl/iGzfsP. A full list of release notes is available at https://developers.google.com/mobile-ads-sdk/docs/admob/ios/rel-notes.

I did rebuilds after each of these steps: clean, deleted the old libGoogleAdMobAds.a of the same name from my source control, removed libGoogleAdMobAds.a from link phase (error’d as expected), re-added it, all to no avail – the simulator build was still showing the same message.

Then I remembered deleting the app from the simulator has historically fixed certain issues (stale app icon/xibs/etc), so I tried that. Worked like a charm.

I think I’ve seen this issue before – but the only way I knew that stale libs were the cause of it was because of the log message. Since upgrading a library usually will support the same old symbols, there generally won’t be a linker error – so this could potentially waste important debugging time with the programmer incorrectly believing he is debugging the newest version of the lib.

I hope and believe that the issue is just in the transfer of the project and ‘overly-clever’ optimization of transferring the app to the simulator that missed a diff case, because the deleting trick worked. Perhaps the transfer diffs only non-linked code – although, I would expect it to include statically linked stuff and only have this issue for dynamic linkage. This took around 15 minutes of messing around to figure out, but it seems like something that could bite back in the future.

Update: I tried this same project on another mac and my iPhone and found that the deprecated message was still there, just deferred, so this post may not be a correct solution. It’s possible that the message itself is bad, but I’m not sure yet. To check my sanity, I did these steps: git fetch/merge to update to the new admob libs (while the project was closed). The problem was different here – it persisted even after cleaning/rebuilding and deleting the app from the device. I restarted Xcode on a hunch, and also tried nuking the derived data folder.

18 Aug 14
16:50

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. google.com 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:

wifiscreen

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
14:21

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;
@end
@implementation YoDogWhatsWrong
- (id)initWithAValue:(float)aFloat anotherValue:(float)someOtherValue
{
    if ((self = [super init])) {
        self.aValue = aFloat;
    }
    return self;
}
@end

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;
@end

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
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.