Building Static Libraries to Share Code on iPhone AND Mac OS X Projects

2010-02-14 19:00:00 -0500


There are numerous good resources out there, like Clint Harris’ excellent tutorial, that describe how one can share common code across iPhone projects by keeping the shared code in a separate project, and including it in your various projects using the cross-project reference technique. The technique is further complicated due to the need to use static libraries for iPhone projects, as dynamic libraries are not allowed by Apple in iPhone apps.

Openssl Xcode GroupsDespite the nuisance, the technique works pretty well, and we’ve been using it as detailed here on Mobile Orchard for building OpenSSL and SQLCipher for iPhone projects. However, recently we started sharing a lot of our SQLCipher-specific code (like our custom data model, etc) with our upcoming Mac OS X application, Strip Sync. Therefore, numerous libraries we were sharing were linked against our openssl-xcode build, which is necessarily a little customized. Using the shared library there worked great for development (“Debug”) builds, but came to a screeching halt once it came time to do a “Release” build.

The Release build process sets up a universal binary. Thus, using the common technique described above, the linker ends up trying to link a PPC build of your binary against our static openssl library, which was only building either i386, or ARMv6. If you are using the code and instructions we described in our SQLCipher tutorial to use SQLCipher in your iPhone project, and you decide to use that technique for a Mac OS X project, this problem will affect you (if you are building the standard universal binary on release builds).

Happily, we’ve got a fix! Once we realized what was going on, I mentioned it to Stephen, who put together our handy openssl-xcode project, that provides you a drop-in way of setting up the static library for iPhone development. In a few minutes he hooked up a new version of the Run Script build phase that sets up the static library to do the usual for iPhone builds, but to detect a universal binary build and do the right thing:


set

if [ "$SDKROOT" != "" ]; then
ISYSROOT="-isysroot $SDKROOT"
fi

## this is a universal build
if [ "$ARCHS_STANDARD_32_BIT" = "i386 ppc" ]; then

mkdir -p temp-universal

BUILDARCH="ppc"
echo "***** BUILDING UNIVERSAL ARCH $BUILDARCH ******"
make clean
./config -openssldir="$BUILD_DIR"
make CC=$PLATFORM_DEVELOPER_BIN_DIR/gcc-4.0 CFLAG="-D_DARWIN_C_SOURCE -arch $BUILDARCH $ISYSROOT" SHARED_LDFLAGS="-arch $BUILDARCH -dynamiclib"
cp libcrypto.a temp-universal/$BUILDARCH-libcrypto.a
cp libssl.a temp-universal/$BUILDARCH-libssl.a

BUILDARCH="i386"
echo "***** BUILDING UNIVERSAL ARCH $BUILDARCH ******"
make clean
./config -openssldir="$BUILD_DIR"
make CC=$PLATFORM_DEVELOPER_BIN_DIR/gcc-4.0 CFLAG="-D_DARWIN_C_SOURCE -arch $BUILDARCH $ISYSROOT" SHARED_LDFLAGS="-arch $BUILDARCH -dynamiclib"
cp libcrypto.a temp-universal/$BUILDARCH-libcrypto.a
cp libssl.a temp-universal/$BUILDARCH-libssl.a

lipo -create temp-universal/*-libcrypto.a -output libcrypto.a
lipo -create temp-universal/*-libssl.a -output libssl.a
else
BUILDARCH=$ARCHS
echo "***** BUILDING ARCH $BUILDARCH ******"
make clean
./config -openssldir="$BUILD_DIR"
make CC=$PLATFORM_DEVELOPER_BIN_DIR/gcc-4.0 CFLAG="-D_DARWIN_C_SOURCE -arch $BUILDARCH $ISYSROOT" SHARED_LDFLAGS="-arch $BUILDARCH -dynamiclib"
fi

ranlib libcrypto.a
ranlib libssl.a
cp libcrypto.a libssl.a "$BUILT_PRODUCTS_DIR"
exit 0

We’ve updated the Github project with this change, so if you are using this technique and openssl-xcode, you can simply download the latest (or pull from github master), and drag and drop the new project file into your XCode build directory and be off and running.

Again, the previous technique worked just fine for sharing code across iPhone projects, but doing a universal build of the static library is absolutely necessary if you use the same shared code in your Mac OS X project and you try to link it against a universally-built binary.

Zetetic is the creator of the encrypted iPhone data vault and password manager Strip and the open source encryption-enhanced database engine SQLCipher.

Encrypted iPhone Applications

2010-02-05 19:00:00 -0500


It was just over four months ago when we set about learning the iPhone SDK and putting together our first application, a revamp of STRIP, the personal information manager that was so popular for the Palm platform.

Now that we’ve got a mostly-finished product (we’re still making a few tweaks and getting ready to start the beta), we took a step back to look at the code we built to keep the development DRY and enable quick development of future applications. Essentially, we’ve built ourselves a framework for building applications that have a fully-encrypted database layer using SQLCipher, with a robust data model, a login facility, random password generation and seeding, etc.

What took us four months to do at first, now only takes us a few days. Using the code we extracted from STRIP we were able to put together one of our other app ideas in less than four work days. Introducing Codebook, a secure notepad:

Codebook Promo

Codebook is a LOT like the built-in Notes application on the iPhone. They aren’t exactly the same, but the critical difference is that no one is getting in and reading your notes unless they have your password:

Codebook Login


Coming Soon: Strip Sync

2010-01-29 19:00:00 -0500

Updated: 6/6/2012 This blog post is out of date, and the software referenced in it, Strip Sync, has been discontinued in favor of Strip for Windows and Strip for OS X.

Strip IconWe’ve been getting a ton of mail lately about Strip, mostly along the lines of, “when will the desktop client be ready?” We’ve made a ton of progress over the last few weeks, and we really appreciate the various letters of encouragement and everyone’s enthusiasm.

Strip Sync

We are calling the initial desktop client Strip Sync. It provides some really critical functionality for the Strip platform going forward, and it will be offered for free here on our website. It runs on Mac OS X 10.5 and later, and most modern versions of Windows (although “modern” feels like a weird term, given the leap into the future that seems to be taking place at the moment). It’s really two separate, native applications that provide the same excellent and much-needed features:

  • Import from CSV – with files from Palm Strip Exporter or any other resource.
  • Synchronization with the iPhone – you’ll be able to bring over your old Palm data.
  • Independent back-up – for many people, the iTunes backup just isn’t enough.

At some point soon Strip Sync will also provide handy export and printing capabilities, but we’re really eager to get these much-asked-for features out there already, so export and print may not be introduced in the initial version. We’ll see soon.

We’re about ready to start looking for beta testers, we’ll post a notice here on the blog soon and send out a message to the mailing list. If you’d like to be added to our mailing list, send us an email, or just fill out the form over on the Strip product page.

Once Strip Sync is out the door we’re going to use it as the basis of the full-featured desktop version of Strip, which will allow you to enter and edit your data from the desktop, as opposed to having to slowly tap away with your thumbs on the iPhone.

What About Android?

We’ve been getting a lot of queries asking for a version of Strip for Android, but this one really jumps out:

Hi,

Years ago, around the turn of the century, I used to work as an
engineer at Palm Digital Media (eBook division of Palm); all of the
devs and admins in our group worshipped your Strip app.

I have recently acquired an Android device (Nexus One). Please release
a version for Android.

Thanks for making one of the most useful applications ever,

We’d really love to do this, I mean, really, love. Right now our hands are a bit full with those two aforementioned native desktop applications! Once we have the desktop component firmly in place, we can begin to explore other platforms like Android, but for now it’s going to have to wait. We do expect to see an explosion of Android devices over the next year or so, and it would be a fantastic addition to the Strip platform.

If you’ve just got to have Strip on your platform of choice, please let us know, we’re listening.


Co-working Open House in Brooklyn 1/29

2010-01-25 19:00:00 -0500


My co-working space, The Change You Want To See, in North-side Williamsburg, is hosting our monthly open house event this Friday, the 29th of January. Anybody is welcome to drop in our space during normal hours, but our open-house event is a great time to meet other local professionals and free-lancers. People tend to be very focused during the day, and then at 5pm we do our happy hour (“beer o’clock”).

So, if you’re thinking of checking out co-working, or you just want to chew my ear off about one of our products, you’ll be most welcome. Do check the link and add your name if you plan on coming.


Tempo API Mailing List

2010-01-14 19:00:00 -0500


Our time-tracking service Tempo has an API available (an Application Programming Interface) that allows our customers to integrate their own software with Tempo directly. In the interests of fostering discussion, sharing tips, and providing another vector for making announcements directly to consumers of the API, I’ve created a mailing list on Zed Shaw’s new service Librelist.

To sign up, simply send any old email to: tempo.api@librelist.com

You will receive a confirmation message, and once you are all confirmed, you should be good to go. If you are running code that integrates with our service, or are building something now, I encourage you to join the list and to share with us any difficulties you experience, that we might share knowledge that so often gets trapped in our “support” email box.

That said, if you want to address an issue privately, you’re always welcome to get in touch with us directly.