how to build PoDoFo library for iOS

2020-07-23 04:39发布

问题:

This may be a copy of this question How can I use the PoDoFo library for annotating PDFs on iOS? not responded yet. i know how to use/create static libraries into xcode projects for iOS. i was looking for a free PDF library which support in memory editing of pdf documents and i came to know that PoDoFo done it very well, i tried to build this library for xcode but i really don't know how to play with CMake. can any body tell me how can i use this library into my iOS application.

thanks

回答1:

This is an extract from Podofo 'Read me' file

CMake builds on Mac OS X

Mac OS X users can build PoDoFo using CMake either by generating conventional UNIX Makefiles (the "Unix Makefiles" CMake target) or generating an XCode project (the "Xcode" target). In either case the following applies.

You will need freetype and fontconfig. It's possible to omit the use of libjpeg (see the platform-independent documentation) but by default libjpeg will also be required. If you have these libraries already (say, from fink or DarwinPorts) you can skip the following section and update the CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH arguments appropriately.

Dependencies

I'll assume you're installing podofo and any required libraries into $HOME/libs . Adjust to taste, but keep it consistent.

The easiest way to get any required libraries is to use MacPorts to install the libjpeg, fontconfig, and freetype libraries. Once you've installed MacPorts, just run:

 /opt/local/bin/port install fontconfig freetype jpeg tiff lua

MacPorts will automatically build the libraries and their dependencies, installing them in /opt/local.

If you want to distribute the libraries with your application, all you'll need to do is use install_name_tool to set appropriate relative paths for their linkage and include them in your application bundle - just like you do with any other libraries.

PoDoFo itself

You should be able to configure and install podofo on Mac OS X using:

    cmake -G "Unix Makefiles" \
        -DWANT_FONTCONFIG:BOOL=TRUE \
        -DCMAKE_INSTALL_PREFIX=/opt/podofo \
        -DCMAKE_INCLUDE_PATH=/opt/local/include \
        -DCMAKE_LIBRARY_PATH=/opt/local/lib \
        ../podofo
    make
    sudo mkdir /opt/podofo
    sudo chown $USER /opt/podofo
    make install

change "Unix Makefiles" to "Xcode" if you want to build an XCode project instead, then instead of running make' andmake install' just open the project file and work as normal

Instead of using 'XCode' in the command, type 'Xcode', (c lowercase) and it should do the trick.