Reorganize code into a separate static library target

Static library makes it easier for people to use the code in their Xcode projects.