ai

Re-signing IPA Files

Scenario: You have an IPA that you want to test on a device, but the IPA was generated using a provisioning profile that does not include the device, and was signed with a certificate that is not yours. You drag this IPA to XCode’s organizer window hoping it would be installed on the connected device, but this results in an Unknown error.

Turns out that this is easy to fix. Here’s how to make it work.

First, unpack the IPA (unzip -q <IPA>). This would create a directory named Payload and a few other files. Delete the existing signature in the extracted package:

rm -rf "Payload/*.app/_CodeSignature" "Payload/*.app/CodeResources"

For the next step, you need two things: a valid provisioning profile and a valid certificate. Both can be obtained via the iOS developer portal.

Replace the provisioning profile first

cp <PROVISIONING_PROFILE> "Payload/*.app/embedded.mobileprovision"

Then resign using your certificate (the certificate must be present in your keychain)

/usr/bin/codesign -f -s "<CERTIFICATE>" --resource-rules "Payload/*.app/ResourceRules.plist" "Payload/*.app"

Now you can recreate the IPA and then drag & drop it in the XCode organizer to install it on the device!

zip -qr <IPA_resigned> Payload     

Edit: If you are looking for user friendly options, check out the script by Daniel or the app by Brian.

Gnuplot Cairo Terminal Errors in Mountain Lion

I love the cairo terminal in gnuplot, it creates amazing plots. My recent upgrade to Mountain Lion broke my homebrew based gnuplot installation, throwing a bunch of glib errors when I set the terminal to pdfcairo or pngcairo (normal terminals work fine):

Error: GLib-GObject-CRITICAL **: gtype.c:2720: You forgot to call g_type_init() 

This is essentially an issue with the latest version of Pango package. There are two ways to fix this:

  • Force homebrew to go back to a lower version of Pango; this error seems to appear in versions 1.32.6 or later.
  • Patch the gnuplot installation’s Cairo terminal as suggested here.

Note: If you are not getting cairo terminals in your gnuplot installation, reinstall it with cairo option enabled: brew install gnuplot --cairo

Latex Tips Collection

Over time, I’ve come across many useful Latex tips and tricks scattered across the internet. Here’s an attempt to collect some of those:

  • Tips for Conference Papers by Gurmeet Singh

    A nice set of tricks that saves your life at the last minute during deadlines.

  • Latex Usage Notes by Eddie Kohler

    Solutions for common Latex problems, tips on proper formatting, etc.

Syncing Folders Outside Dropbox Folder

A big complaint I have about Dropbox is that unlike SugarSync, it does allow me to sync any folder in my computer (essentially, I need to place the folders I want to be synced inside the “Dropbox” folder).

Recently, I found a workaround for this problem. Here’s the trick to syncing any folder in your computer: softlink the folder to your Dropbox folder!

If you’re using a Mac (or Linux), just use the following command:

ln -s /full-path-to-folder/file-to-sync ~/Dropbox/desired-folder-name

That’s it, from now on, all file(s) in the actual path would now sync with Dropbox.

Doxygen and OSX: Graphviz and Other Errors

I’m a big fan of Doxygen. I use it all the time to generate and analyze call trees. Recently, I wanted to use it in my MacbookPro for analyzing an open source project. There is a binary for SnowLeopard here that works in Lion too, but it was throwing lots of errors regarding Graphviz. Here are two things that I had to do to make it finally work:

  • For some reason, long file names do not work in OSX. By default, Doxygen uses long names. So you need to set the SHORT_NAMES to YES in your doxygen file. If you are using the Wizard (GUI), then save your settings file (File->Save), and then manually edit the file in a text editor. 

  • GraphViz is included in the dmg file. You need to set appropriate path to the dot file for graphviz to work. Try setting it to /Applications/Doxygen.app/Contents/Resources. If that fails, then use macports to install graphviz, and use that path.

Making QXDM COM Object Work With Python

Qualcomm’s QXDM is an amazing tool for getting diagnostic information from mobile phones. It supports automation where you can write scripts to interface with the COM object exposed by QXDM.

The default installation of QXDM comes with a number of examples on how to use this object. Unfortunately, all the examples are in Perl. Although I like Perl, recently I have been using Python for all my scripting needs. It’s actually very easy to convert all these scripts to Python. Here’s how:

  • First, you need Python to be able to access COM objects. For this purpose, I used the Python comtypes package. Download and install it from SourceForge.

  • Now, you can do the following in your script:

1
2
3
4
5
6
7
8
from comtypes.client import CreateObject

# For ISF file post-processing
IISF = CreateObject("DMCoreAutomation.ItemStoreFiles")

# For accessing data directly from QXDM. 
# Note that the script needs to be run as admin.
QXDM = CreateObject("QXDM.Application") 

Qualnet 4.0.1 Woes!

For my latest work, I am using the Qualnet simulator tool. Unfortunately, the version that I have access to is pretty old (version 4.0.1). Consequently, I had a lot of trouble getting it to compile in Windows 7. For those who are having the same trouble, see if what I did works for you:

  • This version of Qualnet is only compatible with Visual Studio 2005 (I have tried VS 2008 and VS 2010 - although I succeeded in compiling, the executable crashes all the time). Install VS 2005 if you can get hold of it, or install Visual C++ 2005 Express edition which is available for free.

  • The second thing that is essential for building Qualnet is Windows 7 SDK. Download and install this from Microsoft.

  • Once you have both these installed, run the vsvars32.bat file to set the right environment variables. vsvars32.bat is available in the following folder: C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\

  • Now try compiling qualnet. I used the following command inside c:\qualnet\4.0\main folder:

    nmake /f Makefile-windows-vc8
    
  • For most, the compilation will fail giving errors in oslrv2_nigata.cpp. So go ahead and comment out this file in the makefile present in qualnet\libraries\wireless\src

  • Try compiling again. Now the compiler would throw errors wherever routines from the file that we commented out. I had to comment out its usage wherever compilation broke.

  • Once I did that, compilation went smooth, and I was able to get qualnet working.

ImportError With IronPython in C#

I was using IronPython to execute python code inside my C# implementation lately, and I encountered this error when trying to use xmlrpclib:

ImportError: No module named xmlrpclib.

It was really frustrating because if I try the same in IronPython console, it works fine. It turned out that this was a problem with search paths. When called via C# code, IronPython does not search for missing libraries unless you provide it a path to search for. Here’s how I solved this issue:

  1. First, find out the search paths that IronPython is using in console mode:
1
2
import sys
print sys.path

This will print all the search paths. Save these paths somewhere.

  1. Now include all these search paths inside your C# code:
1
2
3
4
ScriptEngine Engine = Python.CreateEngine();
ICollection<string> Paths = Engine.GetSearchPaths();
Paths.Add("<Path>");
Engine.SetSearchPaths(Paths);

Replace <Path> with the path you saved earlier. Now IronPython will search all these pathsbefore failing with an ImportError.

Conky Like System Monitor for Windows

Ever since I came across Conky, I have been using it on all my machines running Ubuntu (for those who are interested, I use Conky-Colors for easy configuration). I also use Windows extensively and had always wanted to have something similar to Conky. It seems like my quest has finally ended. My good friend suggested that I try RainMeter, and I was impressed with the results! It’s extremely customizable, has tons of skins to choose from, and is not heavy on the system.

Here’s a screenshot (the theme I’m using is JSMeterII):