Skip to content

Instantly share code, notes, and snippets.

@davepeck
Last active November 14, 2020 14:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save davepeck/2be7c233b3baa98f1b9c to your computer and use it in GitHub Desktop.
Save davepeck/2be7c233b3baa98f1b9c to your computer and use it in GitHub Desktop.
How to build libarchive 3 (or, really, any autotools-based library) for iOS 8+

How to build libarchive 3 (and, really, any autotools based library) for iOS 8+

It's easy:

  1. Grab iOS-autotools by @szanni from https://github.com/szanni/ios-autotools
  2. Grab libarchive 3 from http://www.libarchive.org/
  3. cd into the libarchive code directory
  4. export ARCHS="armv7 armv7s arm64" (or suitable for your needs and your shell of choice)
  5. Run autoframework ArchiveLib libarchive.a and wait for everything to build!

From there, you'll end up with both Frameworks (in the aptly named Frameworks/ directory) and per-architecture static libraries (you guessed it: Static/).

These days (the modern iOS 8 and iOS 9 era), I recommend using the Frameworks.

Things to think about

  1. Depending on what you want out of libarchive you'll probably want to also build libbz2 using the same strategy. (http://www.bzip.org/)

  2. Apple scans all binaries for use of private APIs. As it happens, both libarchive and libbz2 are in the iOS SDK, but they are private. These days, Apple's tools seem hip to the idea that names in different frameworks can overlap sanely. Nevertheless, caveat emptor. You might run into issues during the app review process. If so, I'd recommend simply prefixing everything in the sources with a private prefix will do the trick. Annoying, but nothing a little extra automation scripting can't handle.

  3. Bitcode. Not sure what the story is here, yet.

  4. Somebody could definitely package up this process and turn it into a cocoapod so that most developers don't have to take on the pain. Back in the iOS 4 and 5 era, I used to provide a repo on github that did something similar. I guess I just don't have the motivation to do this myself — it really isn't that much pain — but if you do, please let me know about it!

Last updated October 14, 2015.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment