This code follows the example described here. Additional useful links: Sandboxing your library Sandboxing your whole app Example of sandboxing a simple library